aws.vpc.DataAwsVpc cannot be used with VPC id without filtering
See original GitHub issueCommunity Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
cdktf & Language Versions
node: 16.13.0
npm: 8.1.0
cdk: 0.9.4
cdk-tf: 0.9.4
@cdktf/provider-aws: 5.0.33
Affected Resource(s)
Expected Behavior
To be able to use the examples provided on the aws_vpc
data source documentation:
data "aws_vpc" "selected" {
id = "vpc-1234567"
}
And be able to use that with @cdktf/provider-aws
as follows:
import * as aws from '@cdktf/provider-aws';
new aws.vpc.DataAwsVpc(this, 'vpc', {
id: 'vpc-1234567',
});
Actual Behavior
The property id
does not exist on the interface DataAwsVpcConfig
.
Steps to Reproduce
import * as aws from '@cdktf/provider-aws';
new aws.vpc.DataAwsVpc(this, 'vpc', {
id: 'vpc-1234567',
});
Note
This looks like it can be done by using the AWS API filters instead, however documentation for HCL
syntax clearly shows id
being used which would be “more ideal”.
new aws.vpc.DataAwsVpc(this, 'vpc', {
filter: [
{
name: 'vpc-id',
values: [
'vpc-1234567',
],
}
],
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Amazon VPC FAQs
Q: Why should I use Amazon VPC? Amazon VPC enables you to build a virtual network in the AWS cloud - no VPNs,...
Read more >Finding information to connect to a VPC - Amazon QuickSight
In the Amazon VPC console, you can filter by VPC. This option is located at the top left of the console. If you...
Read more >Finding a VPC ID - AMS Advanced User Guide
To find a VPC ID, you can use either the AMS console or API/CLI. ... The second command requests the list of VPCs,...
Read more >Troubleshoot dependency errors when deleting VPCs
I tried to delete my Amazon VPC, but I received a dependency error. ... DeleteVpc operation: The vpc 'vpc-id' has dependencies and cannot...
Read more >Amazon VPC policy examples - Amazon Virtual Private Cloud
By default, IAM users and roles don't have permission to create or modify VPC resources. They also can't perform tasks using the AWS...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the record (as your link seems to be the wrong one 😅)
AWS.accessanalyzer.Accessanalyzer
I took an initial look at fixing this (I’ve looked into something similar in the past) and it’s potentially a bit tricky. It seems that provider schemas tend to mark
id
asoptional
for most (maybe all) resources when really it doesn’t make sense to set it (not sure if Terraform even allows it). We had put some rules in place to try and work around this but they really aren’t working at this time (maybe never did fully). If Terraform is ok with settingid
perhaps the best action is to just listen to the schema and remove custom rules, but if not, we’ll need to some research / experimenting to come up with better rules.