Skip to content

Commit

Permalink
Merge branch 'main' into fix/remove-explicit-ecs-deployment-type-for-…
Browse files Browse the repository at this point in the history
…circuit-breaker
  • Loading branch information
mergify[bot] authored Nov 9, 2022
2 parents 1500b74 + 4bdb18e commit f65b647
Show file tree
Hide file tree
Showing 253 changed files with 6,909 additions and 3,021 deletions.
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-cloudfront/lib/distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ export class Distribution extends Resource implements IDistribution {
} else {
const originIndex = this.boundOrigins.length + 1;
const scope = new Construct(this, `Origin${originIndex}`);
const originId = Names.uniqueId(scope).slice(-ORIGIN_ID_MAX_LENGTH);
const originBindConfig = origin.bind(scope, { originId });
const generatedId = Names.uniqueId(scope).slice(-ORIGIN_ID_MAX_LENGTH);
const originBindConfig = origin.bind(scope, { originId: generatedId });
const originId = originBindConfig.originProperty?.id ?? generatedId;
const duplicateId = this.boundOrigins.find(boundOrigin => boundOrigin.originProperty?.id === originBindConfig.originProperty?.id);
if (duplicateId) {
throw new Error(`Origin with id ${duplicateId.originProperty?.id} already exists. OriginIds must be unique within a distribution`);
Expand Down
54 changes: 54 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,60 @@ describe('origin IDs', () => {
});
});

describe('custom origin ids', () => {
test('test that originId param is respected', () => {
const origin = defaultOrigin(undefined, 'custom-origin-id');

const distribution = new Distribution(stack, 'Http1Distribution', {
defaultBehavior: { origin },
additionalBehaviors: {
secondUsage: {
origin,
},
},
});
distribution.addBehavior(
'thirdUsage',
origin,
);

Template.fromStack(stack).hasResourceProperties('AWS::CloudFront::Distribution', {
DistributionConfig: {
DefaultCacheBehavior: {
CachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6',
Compress: true,
TargetOriginId: 'custom-origin-id',
ViewerProtocolPolicy: 'allow-all',
},
CacheBehaviors: [{
CachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6',
Compress: true,
PathPattern: 'secondUsage',
TargetOriginId: 'custom-origin-id',
ViewerProtocolPolicy: 'allow-all',
},
{
CachePolicyId: '658327ea-f89d-4fab-a63d-7e88639e58f6',
Compress: true,
PathPattern: 'thirdUsage',
TargetOriginId: 'custom-origin-id',
ViewerProtocolPolicy: 'allow-all',
}],
Enabled: true,
HttpVersion: 'http2',
IPV6Enabled: true,
Origins: [{
DomainName: 'www.example.com',
Id: 'custom-origin-id',
CustomOriginConfig: {
OriginProtocolPolicy: 'https-only',
},
}],
},
});
});
});

describe('supported HTTP versions', () => {
test('setting HTTP/1.1 renders HttpVersion correctly', () => {
new Distribution(stack, 'Http1Distribution', {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "DistributionOriginIdDefaultTestDeployAssert16FC3109.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": {}
}
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."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"21.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"413425a9c32869faf78d5031f15a0e8f5eed244599a8c576f6f4c025d23505e6": {
"source": {
"path": "integ-distribution-origin-id.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "413425a9c32869faf78d5031f15a0e8f5eed244599a8c576f6f4c025d23505e6.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"Resources": {
"TestDistribution94EC811C": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"CacheBehaviors": [
{
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"PathPattern": "/second",
"TargetOriginId": "my-custom-origin-id",
"ViewerProtocolPolicy": "allow-all"
},
{
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"PathPattern": "/third",
"TargetOriginId": "my-custom-origin-id",
"ViewerProtocolPolicy": "allow-all"
}
],
"DefaultCacheBehavior": {
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"Compress": true,
"TargetOriginId": "my-custom-origin-id",
"ViewerProtocolPolicy": "allow-all"
},
"Enabled": true,
"HttpVersion": "http2",
"IPV6Enabled": true,
"Origins": [
{
"CustomOriginConfig": {
"OriginProtocolPolicy": "https-only"
},
"DomainName": "www.example.com",
"Id": "my-custom-origin-id"
}
]
}
}
}
},
"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."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "21.0.0",
"testCases": {
"DistributionOriginId/DefaultTest": {
"stacks": [
"integ-distribution-origin-id"
],
"assertionStack": "DistributionOriginId/DefaultTest/DeployAssert",
"assertionStackName": "DistributionOriginIdDefaultTestDeployAssert16FC3109"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"version": "21.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"integ-distribution-origin-id.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "integ-distribution-origin-id.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"integ-distribution-origin-id": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "integ-distribution-origin-id.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/413425a9c32869faf78d5031f15a0e8f5eed244599a8c576f6f4c025d23505e6.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"integ-distribution-origin-id.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"integ-distribution-origin-id.assets"
],
"metadata": {
"/integ-distribution-origin-id/TestDistribution/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "TestDistribution94EC811C"
}
],
"/integ-distribution-origin-id/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/integ-distribution-origin-id/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "integ-distribution-origin-id"
},
"DistributionOriginIdDefaultTestDeployAssert16FC3109.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "DistributionOriginIdDefaultTestDeployAssert16FC3109.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"DistributionOriginIdDefaultTestDeployAssert16FC3109": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "DistributionOriginIdDefaultTestDeployAssert16FC3109.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"DistributionOriginIdDefaultTestDeployAssert16FC3109.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"DistributionOriginIdDefaultTestDeployAssert16FC3109.assets"
],
"metadata": {
"/DistributionOriginId/DefaultTest/DeployAssert/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/DistributionOriginId/DefaultTest/DeployAssert/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "DistributionOriginId/DefaultTest/DeployAssert"
}
}
}
Loading

0 comments on commit f65b647

Please sign in to comment.