Skip to content

Commit

Permalink
refractor vpc connector props
Browse files Browse the repository at this point in the history
  • Loading branch information
DDynamic committed May 25, 2022
1 parent 26ec943 commit 736ea42
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/@aws-cdk/aws-apprunner/lib/vpc-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export class VpcConnector extends cdk.Resource implements IVpcConnector {

return new Import(scope, id);
}
private readonly props: VpcConnectorProps;

/**
* The ARN of the VPC connector.
Expand All @@ -133,23 +132,23 @@ export class VpcConnector extends cdk.Resource implements IVpcConnector {
public readonly connections: Connections

public constructor(scope: Construct, id: string, props: VpcConnectorProps) {
super(scope, id);

this.props = props;
super(scope, id, {
physicalName: props.vpcConnectorName,
});

const securityGroups = this.props.securityGroups?.length ?
this.props.securityGroups
: [new ec2.SecurityGroup(this, 'SecurityGroup', { vpc: this.props.vpc })];
const securityGroups = props.securityGroups?.length ?
props.securityGroups
: [new ec2.SecurityGroup(this, 'SecurityGroup', { vpc: props.vpc })];

const resource = new CfnVpcConnector(this, 'Resource', {
subnets: this.props.vpc.selectSubnets(this.props.vpcSubnets ?? { subnetType: ec2.SubnetType.PRIVATE_WITH_NAT }).subnetIds,
subnets: props.vpc.selectSubnets(props.vpcSubnets ?? { subnetType: ec2.SubnetType.PRIVATE_WITH_NAT }).subnetIds,
securityGroups: securityGroups?.map(securityGroup => securityGroup.securityGroupId),
vpcConnectorName: this.props.vpcConnectorName,
vpcConnectorName: this.physicalName,
});

this.vpcConnectorArn = resource.attrVpcConnectorArn;
this.vpcConnectorRevision = resource.attrVpcConnectorRevision;
this.vpcConnectorName = resource.ref;
this.connections = new Connections({ securityGroups });;
this.connections = new Connections({ securityGroups });
}
}

0 comments on commit 736ea42

Please sign in to comment.