-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(route53): vpc region in template overridden by stack region (#20530)
Fixes #20496 This PR implements the proposed change in #20496 - When a region is set in the vpc it is used in the CloudFormation template. Otherwise the region from the respective stack is used. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
17 changed files
with
1,064 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as cdk from '@aws-cdk/core'; | ||
import { IntegTest } from '@aws-cdk/integ-tests'; | ||
import * as ec2 from '../lib'; | ||
|
||
const appWithVpc = new cdk.App(); | ||
const stack = new cdk.Stack(appWithVpc, 'StackWithVpc', { | ||
env: { | ||
region: 'eu-west-1', | ||
account: '123456', | ||
}, | ||
}); | ||
|
||
const testVpc = new ec2.Vpc(stack, 'MyVpc', { | ||
vpcName: 'my-vpc-name', | ||
}); | ||
|
||
const appUnderTest = new cdk.App(); | ||
const stackLookup = new cdk.Stack(appUnderTest, 'StackUnderTest', { | ||
env: { | ||
region: 'us-east-2', | ||
account: '123456', | ||
}, | ||
}); | ||
|
||
const vpcFromVpcAttributes = ec2.Vpc.fromVpcAttributes(stackLookup, 'VpcFromVpcAttributes', { | ||
region: 'eu-west-1', | ||
availabilityZones: ['eu-west-1a'], | ||
vpcId: testVpc.vpcId, | ||
}); | ||
|
||
const vpcFromLookup = ec2.Vpc.fromLookup(stack, 'VpcFromLookup', { | ||
region: 'eu-west-1', | ||
vpcName: 'my-vpc-name', | ||
}); | ||
|
||
new cdk.CfnOutput(stackLookup, 'OutputFromVpcAttributes', { | ||
value: `Region fromVpcAttributes: ${vpcFromVpcAttributes.env.region}`, | ||
}); | ||
|
||
new cdk.CfnOutput(stackLookup, 'OutputFromLookup', { | ||
value: `Region fromLookup: ${vpcFromLookup.env.region}`, | ||
}); | ||
|
||
new IntegTest(appUnderTest, 'ArchiveTest', { | ||
testCases: [stackLookup], | ||
}); | ||
appWithVpc.synth(); | ||
appUnderTest.synth(); |
19 changes: 19 additions & 0 deletions
19
...ec2/test/vpc-lookup.integ.snapshot/ArchiveTestDefaultTestDeployAssert3405726A.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "ArchiveTestDefaultTestDeployAssert3405726A.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
36 changes: 36 additions & 0 deletions
36
...2/test/vpc-lookup.integ.snapshot/ArchiveTestDefaultTestDeployAssert3405726A.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/@aws-cdk/aws-ec2/test/vpc-lookup.integ.snapshot/StackUnderTest.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"cfac1423efb7c99cadc3f40367c753fe5b1527d9a6950c096ba326fabac4c89f": { | ||
"source": { | ||
"path": "StackUnderTest.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"123456-us-east-2": { | ||
"bucketName": "cdk-hnb659fds-assets-123456-us-east-2", | ||
"objectKey": "cfac1423efb7c99cadc3f40367c753fe5b1527d9a6950c096ba326fabac4c89f.json", | ||
"region": "us-east-2", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-file-publishing-role-123456-us-east-2" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/@aws-cdk/aws-ec2/test/vpc-lookup.integ.snapshot/StackUnderTest.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"Outputs": { | ||
"OutputFromVpcAttributes": { | ||
"Value": "Region fromVpcAttributes: eu-west-1" | ||
}, | ||
"OutputFromLookup": { | ||
"Value": "Region fromLookup: eu-west-1" | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/@aws-cdk/aws-ec2/test/vpc-lookup.integ.snapshot/StackWithVpc.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"628a32283150d3af24efb3a11967996306884a3835ac731ab35822da2ce7e9ff": { | ||
"source": { | ||
"path": "StackWithVpc.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"123456-eu-west-1": { | ||
"bucketName": "cdk-hnb659fds-assets-123456-eu-west-1", | ||
"objectKey": "628a32283150d3af24efb3a11967996306884a3835ac731ab35822da2ce7e9ff.json", | ||
"region": "eu-west-1", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::123456:role/cdk-hnb659fds-file-publishing-role-123456-eu-west-1" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
Oops, something went wrong.