Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We have to rename complex ImportProps fields #2206

Closed
rix0rrr opened this issue Apr 9, 2019 · 0 comments
Closed

We have to rename complex ImportProps fields #2206

rix0rrr opened this issue Apr 9, 2019 · 0 comments
Assignees
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. package/awscl Cross-cutting issues related to the AWS Construct Library pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Apr 9, 2019

See the following code:

 const vpc = VpcNetwork.import(this, 'VpcSviluppo', {
       vpcId: 'vpc-0e0311c34e5d7c8ac',
       availabilityZones: ['eu-west-1a','eu-west-1b','eu-west-1c'],
       publicSubnetIds: [
         'subnet-0c2fda469e286aa78',
         'subnet-030da2fd20cae22b3',
         'subnet-0dd5750486e28414d'
       ]
    });
 

 const defaultSecurityGroup = SecurityGroup.import(this, 'SviluppoSecurityGroup', {
       securityGroupId: 'sg-062d4c1255df27688', //default-sviluppo
});
 
const cluster = Cluster.import(this, 'Fargate', {
    clusterArn: 'arn:aws:ecs:eu-west-1:xxxxxxx:cluster/fargate',
    clusterName: 'fargate',
    vpc: vpc,
    securityGroups: [
        defaultSecurityGroup
    ]
});

Looks correct, right? And TSC doesn't complain. It is, however, wrong. You're supposed to do this:

const cluster = Cluster.import(this, 'Fargate', {
    clusterArn: 'arn:aws:ecs:eu-west-1:xxxxxxx:cluster/fargate',
    clusterName: 'fargate',
    vpc: {
       vpcId: 'vpc-0e0311c34e5d7c8ac',
       availabilityZones: ['eu-west-1a','eu-west-1b','eu-west-1c'],
       publicSubnetIds: [
         'subnet-0c2fda469e286aa78',
         'subnet-030da2fd20cae22b3',
         'subnet-0dd5750486e28414d'
       ]
    },
    securityGroups: [
        {
       securityGroupId: 'sg-062d4c1255df27688', //default-sviluppo
      }
    ]
});

TSC accepts this because vpcId is a property on both VpcNetworkImportProps and IVpcNetwork, and all the other fields are optional.

I have spoken to at least 3 people who have made this mistake, and it seems to fit the pattern of the rest of the CDK. We have to fix this, either by making Cluster.import() take an actual IVpcNetwork like everyone is expecting it to, or renaming the field something like vpcImportProps.

I don't know how much of this is going to be taken care of by #1546, but whatever is left after that should be fixed.

@NGL321 NGL321 added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Sep 10, 2019
@NGL321 NGL321 added package/awscl Cross-cutting issues related to the AWS Construct Library package/vpc pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Sep 10, 2019
@eladb eladb closed this as completed Sep 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. package/awscl Cross-cutting issues related to the AWS Construct Library pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

No branches or pull requests

4 participants