From 943abe877cfbcbb54311e2ecc4a9a3bfb231a202 Mon Sep 17 00:00:00 2001 From: Michael Sambol Date: Thu, 21 Dec 2023 16:25:06 -0600 Subject: [PATCH] feat(globalaccelerator): add support for ip addresses and type (#28055) Closes #28051, #28209. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...efaultTestDeployAssertFE50B593.assets.json | 19 +++ ...aultTestDeployAssertFE50B593.template.json | 36 +++++ .../cdk.out | 1 + ...al-accelerator-ip-address-type.assets.json | 19 +++ ...-accelerator-ip-address-type.template.json | 46 +++++++ .../integ.json | 12 ++ .../manifest.json | 113 ++++++++++++++++ .../tree.json | 127 ++++++++++++++++++ ...integ.globalaccelerator-ip-address-type.ts | 18 +++ ...efaultTestDeployAssertCA235111.assets.json | 2 +- .../cdk.out | 2 +- ...global-accelerator-unique-name.assets.json | 6 +- ...obal-accelerator-unique-name.template.json | 4 +- .../integ.json | 2 +- .../manifest.json | 15 ++- .../tree.json | 8 +- .../aws-globalaccelerator/README.md | 12 ++ .../aws-globalaccelerator/lib/accelerator.ts | 119 +++++++++++++++- .../test/globalaccelerator.test.ts | 71 +++++++++- 19 files changed, 616 insertions(+), 16 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets.json new file mode 100644 index 0000000000000..575c9f76edcb3 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets.json @@ -0,0 +1,19 @@ +{ + "version": "35.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.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": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "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." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c5cb2e5de6344 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.assets.json new file mode 100644 index 0000000000000..c7050f20c8248 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.assets.json @@ -0,0 +1,19 @@ +{ + "version": "35.0.0", + "files": { + "47744c3cc21fb0c0e29cdb8642c547ef19256315a25557df8546037677381323": { + "source": { + "path": "global-accelerator-ip-address-type.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "47744c3cc21fb0c0e29cdb8642c547ef19256315a25557df8546037677381323.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.template.json new file mode 100644 index 0000000000000..de80846383032 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/global-accelerator-ip-address-type.template.json @@ -0,0 +1,46 @@ +{ + "Resources": { + "Accelerator8EB0B6B1": { + "Type": "AWS::GlobalAccelerator::Accelerator", + "Properties": { + "Enabled": true, + "IpAddressType": "DUAL_STACK", + "Name": "acceleratorWithIpAddressType" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "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." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/integ.json new file mode 100644 index 0000000000000..3004bb9075474 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "35.0.0", + "testCases": { + "GlobalAcceleratorIpAddressType/DefaultTest": { + "stacks": [ + "global-accelerator-ip-address-type" + ], + "assertionStack": "GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert", + "assertionStackName": "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/manifest.json new file mode 100644 index 0000000000000..c34258606a30a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/manifest.json @@ -0,0 +1,113 @@ +{ + "version": "35.0.0", + "artifacts": { + "global-accelerator-ip-address-type.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "global-accelerator-ip-address-type.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "global-accelerator-ip-address-type": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "global-accelerator-ip-address-type.template.json", + "terminationProtection": false, + "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}/47744c3cc21fb0c0e29cdb8642c547ef19256315a25557df8546037677381323.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "global-accelerator-ip-address-type.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": [ + "global-accelerator-ip-address-type.assets" + ], + "metadata": { + "/global-accelerator-ip-address-type/Accelerator/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Accelerator8EB0B6B1" + } + ], + "/global-accelerator-ip-address-type/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/global-accelerator-ip-address-type/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "global-accelerator-ip-address-type" + }, + "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.template.json", + "terminationProtection": false, + "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": [ + "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.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": [ + "GlobalAcceleratorIpAddressTypeDefaultTestDeployAssertFE50B593.assets" + ], + "metadata": { + "/GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/tree.json new file mode 100644 index 0000000000000..ee2b632c13937 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.js.snapshot/tree.json @@ -0,0 +1,127 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "global-accelerator-ip-address-type": { + "id": "global-accelerator-ip-address-type", + "path": "global-accelerator-ip-address-type", + "children": { + "Accelerator": { + "id": "Accelerator", + "path": "global-accelerator-ip-address-type/Accelerator", + "children": { + "Resource": { + "id": "Resource", + "path": "global-accelerator-ip-address-type/Accelerator/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::GlobalAccelerator::Accelerator", + "aws:cdk:cloudformation:props": { + "enabled": true, + "ipAddressType": "DUAL_STACK", + "name": "acceleratorWithIpAddressType" + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "global-accelerator-ip-address-type/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "global-accelerator-ip-address-type/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "GlobalAcceleratorIpAddressType": { + "id": "GlobalAcceleratorIpAddressType", + "path": "GlobalAcceleratorIpAddressType", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "GlobalAcceleratorIpAddressType/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "GlobalAcceleratorIpAddressType/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "GlobalAcceleratorIpAddressType/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.ts new file mode 100644 index 0000000000000..9047c1ec945af --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-ip-address-type.ts @@ -0,0 +1,18 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import * as ga from 'aws-cdk-lib/aws-globalaccelerator'; + +const app = new App({}); + +const stack = new Stack(app, 'global-accelerator-ip-address-type'); + +new ga.Accelerator(stack, 'Accelerator', { + acceleratorName: 'acceleratorWithIpAddressType', + ipAddressType: ga.IpAddressType.DUAL_STACK, +}); + +new IntegTest(app, 'GlobalAcceleratorIpAddressType', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/GlobalAcceleratorUniqueNameDefaultTestDeployAssertCA235111.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/GlobalAcceleratorUniqueNameDefaultTestDeployAssertCA235111.assets.json index 638d569ab5c46..ac4e559db804f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/GlobalAcceleratorUniqueNameDefaultTestDeployAssertCA235111.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/GlobalAcceleratorUniqueNameDefaultTestDeployAssertCA235111.assets.json @@ -1,5 +1,5 @@ { - "version": "31.0.0", + "version": "35.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/cdk.out index 7925065efbcc4..c5cb2e5de6344 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"31.0.0"} \ No newline at end of file +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.assets.json index 632ad8edb4ed9..9a91c93ef020a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.assets.json @@ -1,7 +1,7 @@ { - "version": "31.0.0", + "version": "35.0.0", "files": { - "0878b70e8e50789495d8912191b4f71d0564827682a0fffa7801d540fad94e83": { + "c23e37bb9e549e184722a2fabaa890032fa56a11b7bd9e2c63511e075175d12a": { "source": { "path": "global-accelerator-unique-name.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "0878b70e8e50789495d8912191b4f71d0564827682a0fffa7801d540fad94e83.json", + "objectKey": "c23e37bb9e549e184722a2fabaa890032fa56a11b7bd9e2c63511e075175d12a.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.template.json index bcc6aeb9b211f..ea14599ce4361 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/global-accelerator-unique-name.template.json @@ -3,8 +3,8 @@ "Accelerator8EB0B6B1": { "Type": "AWS::GlobalAccelerator::Accelerator", "Properties": { - "Name": "globalacceleratoruniquenameAccelerator519EC5EE", - "Enabled": true + "Enabled": true, + "Name": "globalacceleratoruniquenameAccelerator519EC5EE" } } }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/integ.json index f5e0d5fd0e4d5..1cf7bae20641c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "31.0.0", + "version": "35.0.0", "testCases": { "GlobalAcceleratorUniqueName/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/manifest.json index f0a419f321ffc..022b73705cfe8 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "31.0.0", + "version": "35.0.0", "artifacts": { "global-accelerator-unique-name.assets": { "type": "cdk:asset-manifest", @@ -14,10 +14,11 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "global-accelerator-unique-name.template.json", + "terminationProtection": false, "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}/0878b70e8e50789495d8912191b4f71d0564827682a0fffa7801d540fad94e83.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c23e37bb9e549e184722a2fabaa890032fa56a11b7bd9e2c63511e075175d12a.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -50,6 +51,15 @@ "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } + ], + "AccIpAddressTypeB72ABC9C": [ + { + "type": "aws:cdk:logicalId", + "data": "AccIpAddressTypeB72ABC9C", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } ] }, "displayName": "global-accelerator-unique-name" @@ -67,6 +77,7 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "GlobalAcceleratorUniqueNameDefaultTestDeployAssertCA235111.template.json", + "terminationProtection": false, "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}", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/tree.json index 11b05e24f4c9e..18d0cf0a03ee5 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-globalaccelerator/test/integ.globalaccelerator-unique-name.js.snapshot/tree.json @@ -18,8 +18,8 @@ "attributes": { "aws:cdk:cloudformation:type": "AWS::GlobalAccelerator::Accelerator", "aws:cdk:cloudformation:props": { - "name": "globalacceleratoruniquenameAccelerator519EC5EE", - "enabled": true + "enabled": true, + "name": "globalacceleratoruniquenameAccelerator519EC5EE" } }, "constructInfo": { @@ -68,7 +68,7 @@ "path": "GlobalAcceleratorUniqueName/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.270" + "version": "10.3.0" } }, "DeployAssert": { @@ -114,7 +114,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.270" + "version": "10.3.0" } } }, diff --git a/packages/aws-cdk-lib/aws-globalaccelerator/README.md b/packages/aws-cdk-lib/aws-globalaccelerator/README.md index 8f0955e899ac7..8630620939dea 100644 --- a/packages/aws-cdk-lib/aws-globalaccelerator/README.md +++ b/packages/aws-cdk-lib/aws-globalaccelerator/README.md @@ -53,6 +53,18 @@ listener.addEndpointGroup('Group2', { }); ``` +### Create an Accelerator with IP addresses and IP address type + +```ts +const accelerator = new globalaccelerator.Accelerator(this, 'Accelerator', { + ipAddresses: [ + '1.1.1.1', + '2.2.2.2', + ], + ipAddressType: globalaccelerator.IpAddressType.IPV4, +}); +``` + ## Concepts The **Accelerator** construct defines a Global Accelerator resource. diff --git a/packages/aws-cdk-lib/aws-globalaccelerator/lib/accelerator.ts b/packages/aws-cdk-lib/aws-globalaccelerator/lib/accelerator.ts index 5058f170e0007..ecf2c587bfed1 100644 --- a/packages/aws-cdk-lib/aws-globalaccelerator/lib/accelerator.ts +++ b/packages/aws-cdk-lib/aws-globalaccelerator/lib/accelerator.ts @@ -8,7 +8,7 @@ import * as cdk from '../../core'; */ export interface IAccelerator extends cdk.IResource { /** - * The ARN of the accelerator + * The ARN of the accelerator. * * @attribute */ @@ -21,6 +21,28 @@ export interface IAccelerator extends cdk.IResource { * @attribute */ readonly dnsName: string; + + /** + * The DNS name that Global Accelerator creates that points to a dual-stack accelerator's four static IP addresses: + * two IPv4 addresses and two IPv6 addresses. + * + * @attribute + */ + readonly dualStackDnsName?: string; + + /** + * The array of IPv4 addresses in the IP address set. An IP address set can have a maximum of two IP addresses. + * + * @attribute + */ + readonly ipv4Addresses?: string[]; + + /** + * The array of IPv6 addresses in the IP address set. An IP address set can have a maximum of two IP addresses. + * + * @attribute + */ + readonly ipv6Addresses?: string[]; } /** @@ -40,6 +62,33 @@ export interface AcceleratorProps { * @default true */ readonly enabled?: boolean; + + /** + * IP addresses associated with the accelerator. + * + * Optionally, if you've added your own IP address pool to Global Accelerator (BYOIP), you can choose IP + * addresses from your own pool to use for the accelerator's static IP addresses when you create an accelerator. + * You can specify one or two addresses, separated by a comma. Do not include the /32 suffix. + * + * Only one IP address from each of your IP address ranges can be used for each accelerator. If you specify + * only one IP address from your IP address range, Global Accelerator assigns a second static IP address for + * the accelerator from the AWS IP address pool. + * + * Note that you can't update IP addresses for an existing accelerator. To change them, you must create a + * new accelerator with the new addresses. + * + * @default - undefined. IP addresses will be from Amazon's pool of IP addresses. + */ + readonly ipAddresses?: string[]; + + /** + * The IP address type that an accelerator supports. + * + * For a standard accelerator, the value can be IPV4 or DUAL_STACK. + * + * @default - "IPV4" + */ + readonly ipAddressType?: IpAddressType; } /** @@ -55,6 +104,42 @@ export interface AcceleratorAttributes { * The DNS name of the accelerator */ readonly dnsName: string; + + /** + * The DNS name that points to the dual-stack accelerator's four static IP addresses: two IPv4 addresses and two IPv6 addresses. + * + * @default - undefined + */ + readonly dualStackDnsName?: string; + + /** + * The array of IPv4 addresses in the IP address set + * + * @default - undefined + */ + readonly ipv4Addresses?: string[]; + + /** + * The array of IPv6 addresses in the IP address set + * + * @default - undefined + */ + readonly ipv6Addresses?: string[]; +} + +/** + * The IP address type that an accelerator supports. + */ +export enum IpAddressType { + /** + * IPV4 + */ + IPV4 = 'IPV4', + + /** + * DUAL_STACK + */ + DUAL_STACK = 'DUAL_STACK', } /** @@ -68,6 +153,9 @@ export class Accelerator extends cdk.Resource implements IAccelerator { class Import extends cdk.Resource implements IAccelerator { public readonly acceleratorArn = attrs.acceleratorArn; public readonly dnsName = attrs.dnsName; + public readonly dualStackDnsName = attrs.dualStackDnsName; + public readonly ipv4Addresses = attrs.ipv4Addresses; + public readonly ipv6Addresses = attrs.ipv6Addresses; } return new Import(scope, id); } @@ -82,20 +170,43 @@ export class Accelerator extends cdk.Resource implements IAccelerator { */ public readonly dnsName: string; + /** + * The DNS name that points to the dual-stack accelerator's four static IP addresses: + * two IPv4 addresses and two IPv6 addresses. + */ + public readonly dualStackDnsName?: string; + + /** + * The array of IPv4 addresses in the IP address set + */ + public readonly ipv4Addresses?: string[]; + + /** + * The array of IPv6 addresses in the IP address set + */ + public readonly ipv6Addresses?: string[]; + constructor(scope: Construct, id: string, props: AcceleratorProps = {}) { super(scope, id); this.validateAcceleratorName(props.acceleratorName); + this.validateIpAddresses(props.ipAddresses); + const name = props.acceleratorName ?? cdk.Names.uniqueResourceName(this, { maxLength: 64, }); const resource = new ga.CfnAccelerator(this, 'Resource', { enabled: props.enabled ?? true, name, + ipAddresses: props.ipAddresses, + ipAddressType: props.ipAddressType, }); this.acceleratorArn = resource.attrAcceleratorArn; this.dnsName = resource.attrDnsName; + this.dualStackDnsName = resource.attrDualStackDnsName; + this.ipv4Addresses = resource.attrIpv4Addresses; + this.ipv6Addresses = resource.attrIpv6Addresses; } /** @@ -113,4 +224,10 @@ export class Accelerator extends cdk.Resource implements IAccelerator { throw new Error(`Invalid acceleratorName value ${name}, must have length between 1 and 64, got: ${name.length}`); } } + + private validateIpAddresses(ipAddresses?: string[]) { + if (ipAddresses !== undefined && (ipAddresses.length < 1 || ipAddresses.length > 2)) { + throw new Error(`Invalid ipAddresses value [${ipAddresses}], you can specify one or two addresses, got: ${ipAddresses.length}`); + } + } } diff --git a/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts b/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts index 8ab34df895e7e..b1ea83937a71c 100644 --- a/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts +++ b/packages/aws-cdk-lib/aws-globalaccelerator/test/globalaccelerator.test.ts @@ -1,5 +1,5 @@ import { testFixture } from './util'; -import { Template } from '../../assertions'; +import { Match, Template } from '../../assertions'; import { Duration } from '../../core'; import * as ga from '../lib'; @@ -225,6 +225,47 @@ test('create accelerator with uniqueResourceName if acceleratorName is not speci }); }); +test('create accelerator with IpAddresses and IpAddressType', () => { + // GIVEN + const { stack } = testFixture(); + + // WHEN + const acc = new ga.Accelerator(stack, 'Accelerator', { + ipAddresses: [ + '1.1.1.1', + '2.2.2.2', + ], + ipAddressType: ga.IpAddressType.DUAL_STACK, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::GlobalAccelerator::Accelerator', { + Enabled: true, + Name: 'StackAccelerator472129D8', + IpAddresses: [ + '1.1.1.1', + '2.2.2.2', + ], + IpAddressType: 'DUAL_STACK', + }); +}); + +test('create accelerator with no IpAddresses and IpAddressType', () => { + // GIVEN + const { stack } = testFixture(); + + // WHEN + new ga.Accelerator(stack, 'Accelerator'); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::GlobalAccelerator::Accelerator', { + Enabled: true, + Name: 'StackAccelerator472129D8', + IpAddresses: Match.absent(), + IpAddressType: Match.absent(), + }); +}); + test('should validate acceleratorName minimum and maximum length', () => { const { stack } = testFixture(); @@ -239,3 +280,31 @@ test('should validate acceleratorName minimum and maximum length', () => { }); }).toThrowError(/must have length between 1 and 64/); }); + +test('should validate ipAddresses minimum and maximum length', () => { + const { stack } = testFixture(); + + expect(() => { + new ga.Accelerator(stack, 'Acc1', {}); + }).not.toThrow(); + expect(() => { + new ga.Accelerator(stack, 'Acc2', { + ipAddresses: ['1.1.1.1'], + }); + }).not.toThrow(); + expect(() => { + new ga.Accelerator(stack, 'Acc3', { + ipAddresses: ['1.1.1.1', '2.2.2.2'], + }); + }).not.toThrow(); + expect(() => { + new ga.Accelerator(stack, 'Acc4', { + ipAddresses: [], + }); + }).toThrow('Invalid ipAddresses value [], you can specify one or two addresses, got: 0'); + expect(() => { + new ga.Accelerator(stack, 'Acc5', { + ipAddresses: ['1.1.1.1', '2.2.2.2', '3.3.3.3'], + }); + }).toThrow('Invalid ipAddresses value [1.1.1.1,2.2.2.2,3.3.3.3], you can specify one or two addresses, got: 3'); +});