question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws.vpc.DataAwsVpc cannot be used with VPC id without filtering

See original GitHub issue

Community 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:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ansgarmcommented, Apr 27, 2022

For the record (as your link seems to be the wrong one 😅) AWS.accessanalyzer.Accessanalyzer

1reaction
jsteinichcommented, Mar 1, 2022

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 as optional 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 setting id 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found