From 320e4bf7e82f5e9889b6c79b7af1dd456838410d Mon Sep 17 00:00:00 2001 From: maz Date: Mon, 27 May 2024 20:59:01 +0900 Subject: [PATCH 1/5] feat: add ipAddressType property to the AppRunner Service class --- .../@aws-cdk/aws-apprunner-alpha/README.md | 18 +- .../aws-apprunner-alpha/lib/service.ts | 25 ++- ...efaultTestDeployAssertAC7DD6FC.assets.json | 19 ++ ...aultTestDeployAssertAC7DD6FC.template.json | 36 ++++ .../cdk.out | 1 + ...nteg-apprunner-ip-address-type.assets.json | 19 ++ ...eg-apprunner-ip-address-type.template.json | 104 +++++++++ .../integ.json | 12 ++ .../manifest.json | 125 +++++++++++ .../tree.json | 201 ++++++++++++++++++ .../test/integ.service-ip-address-type.ts | 27 +++ .../aws-apprunner-alpha/test/service.test.ts | 23 +- 12 files changed, 606 insertions(+), 4 deletions(-) create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json create mode 100644 packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts diff --git a/packages/@aws-cdk/aws-apprunner-alpha/README.md b/packages/@aws-cdk/aws-apprunner-alpha/README.md index 1cc9363c8c139..c4321b925a798 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/README.md +++ b/packages/@aws-cdk/aws-apprunner-alpha/README.md @@ -32,7 +32,7 @@ The `Service` construct allows you to create AWS App Runner services with `ECR P - `Source.fromEcr()` - To define the source repository from `ECR`. - `Source.fromEcrPublic()` - To define the source repository from `ECR Public`. - `Source.fromGitHub()` - To define the source repository from the `Github repository`. -- `Source.fromAsset()` - To define the source from local asset directory. +- `Source.fromAsset()` - To define the source from local asset directory. The `Service` construct implements `IGrantable`. @@ -180,10 +180,24 @@ new apprunner.Service(this, 'Service', { }); ``` +## Dual Stack + +To use dual stack (IPv4 and IPv6) for your incoming public network configuration, set `ipAddressType` to `IpAddressType.DUAL_STACK`. + +```ts +new apprunner.Service(this, 'Service', { + source: apprunner.Source.fromEcrPublic({ + imageConfiguration: { port: 8000 }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), + ipAddressType: apprunner.IpAddressType.DUAL_STACK, +}); +``` + ## Secrets Manager To include environment variables integrated with AWS Secrets Manager, use the `environmentSecrets` attribute. -You can use the `addSecret` method from the App Runner `Service` class to include secrets from outside the +You can use the `addSecret` method from the App Runner `Service` class to include secrets from outside the service definition. ```ts diff --git a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts index 9564bbae18cf3..89539aa78f180 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts @@ -79,7 +79,7 @@ export class Cpu { * * @param unit The unit of CPU. */ - private constructor(public readonly unit: string) {} + private constructor(public readonly unit: string) { } } /** @@ -715,6 +715,13 @@ export interface ServiceProps { * @default - no health check configuration */ readonly healthCheck?: HealthCheck; + + /** + * The IP address type for your incoming public network configuration. + * + * @default - IPV4 + */ + readonly ipAddressType?: IpAddressType; } /** @@ -996,6 +1003,21 @@ export class HealthCheck { } } +/** + * The IP address type for your incoming public network configuration. + */ +export enum IpAddressType { + /** + * IPV4 + */ + IPV4 = 'IPV4', + + /** + * DUAL_STACK + */ + DUAL_STACK = 'DUAL_STACK', +} + /** * Attributes for the App Runner Service */ @@ -1244,6 +1266,7 @@ export class Service extends cdk.Resource implements iam.IGrantable { egressType: this.props.vpcConnector ? 'VPC' : 'DEFAULT', vpcConnectorArn: this.props.vpcConnector?.vpcConnectorArn, }, + ipAddressType: this.props.ipAddressType, }, healthCheckConfiguration: this.props.healthCheck ? this.props.healthCheck.bind() : diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json new file mode 100644 index 0000000000000..c1ed20a783b61 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.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/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.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/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json new file mode 100644 index 0000000000000..3edc2aa75e54b --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "f9e956fb5e2f791153ea7f9505e67fce8b218eac61d16971b414879ba0b5e11d": { + "source": { + "path": "integ-apprunner-ip-address-type.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "f9e956fb5e2f791153ea7f9505e67fce8b218eac61d16971b414879ba0b5e11d.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/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json new file mode 100644 index 0000000000000..03051f42579aa --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ-apprunner-ip-address-type.template.json @@ -0,0 +1,104 @@ +{ + "Resources": { + "ServiceInstanceRoleDFA90CEC": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "tasks.apprunner.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "ServiceDBC79909": { + "Type": "AWS::AppRunner::Service", + "Properties": { + "InstanceConfiguration": { + "InstanceRoleArn": { + "Fn::GetAtt": [ + "ServiceInstanceRoleDFA90CEC", + "Arn" + ] + } + }, + "NetworkConfiguration": { + "EgressConfiguration": { + "EgressType": "DEFAULT" + }, + "IpAddressType": "DUAL_STACK" + }, + "ServiceName": "service", + "SourceConfiguration": { + "AuthenticationConfiguration": {}, + "AutoDeploymentsEnabled": false, + "ImageRepository": { + "ImageConfiguration": { + "Port": "8000" + }, + "ImageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest", + "ImageRepositoryType": "ECR_PUBLIC" + } + } + } + } + }, + "Outputs": { + "URL": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Fn::GetAtt": [ + "ServiceDBC79909", + "ServiceUrl" + ] + } + ] + ] + } + } + }, + "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/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json new file mode 100644 index 0000000000000..40c51edee8188 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "AppRunnerIpAddressType/DefaultTest": { + "stacks": [ + "integ-apprunner-ip-address-type" + ], + "assertionStack": "AppRunnerIpAddressType/DefaultTest/DeployAssert", + "assertionStackName": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json new file mode 100644 index 0000000000000..1f50a8f75aebc --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/manifest.json @@ -0,0 +1,125 @@ +{ + "version": "36.0.0", + "artifacts": { + "integ-apprunner-ip-address-type.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-apprunner-ip-address-type.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-apprunner-ip-address-type": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integ-apprunner-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}/f9e956fb5e2f791153ea7f9505e67fce8b218eac61d16971b414879ba0b5e11d.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-apprunner-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": [ + "integ-apprunner-ip-address-type.assets" + ], + "metadata": { + "/integ-apprunner-ip-address-type/Service/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ServiceInstanceRoleDFA90CEC" + } + ], + "/integ-apprunner-ip-address-type/Service/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ServiceDBC79909" + } + ], + "/integ-apprunner-ip-address-type/URL": [ + { + "type": "aws:cdk:logicalId", + "data": "URL" + } + ], + "/integ-apprunner-ip-address-type/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-apprunner-ip-address-type/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-apprunner-ip-address-type" + }, + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.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": [ + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.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": [ + "AppRunnerIpAddressTypeDefaultTestDeployAssertAC7DD6FC.assets" + ], + "metadata": { + "/AppRunnerIpAddressType/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/AppRunnerIpAddressType/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "AppRunnerIpAddressType/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json new file mode 100644 index 0000000000000..06ea3cb77a255 --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.js.snapshot/tree.json @@ -0,0 +1,201 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-apprunner-ip-address-type": { + "id": "integ-apprunner-ip-address-type", + "path": "integ-apprunner-ip-address-type", + "children": { + "Service": { + "id": "Service", + "path": "integ-apprunner-ip-address-type/Service", + "children": { + "InstanceRole": { + "id": "InstanceRole", + "path": "integ-apprunner-ip-address-type/Service/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "integ-apprunner-ip-address-type/Service/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-apprunner-ip-address-type/Service/InstanceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "tasks.apprunner.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-apprunner-ip-address-type/Service/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::AppRunner::Service", + "aws:cdk:cloudformation:props": { + "instanceConfiguration": { + "instanceRoleArn": { + "Fn::GetAtt": [ + "ServiceInstanceRoleDFA90CEC", + "Arn" + ] + } + }, + "networkConfiguration": { + "egressConfiguration": { + "egressType": "DEFAULT" + }, + "ipAddressType": "DUAL_STACK" + }, + "serviceName": "service", + "sourceConfiguration": { + "authenticationConfiguration": {}, + "autoDeploymentsEnabled": false, + "imageRepository": { + "imageConfiguration": { + "port": "8000" + }, + "imageIdentifier": "public.ecr.aws/aws-containers/hello-app-runner:latest", + "imageRepositoryType": "ECR_PUBLIC" + } + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_apprunner.CfnService", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "URL": { + "id": "URL", + "path": "integ-apprunner-ip-address-type/URL", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-apprunner-ip-address-type/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-apprunner-ip-address-type/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "AppRunnerIpAddressType": { + "id": "AppRunnerIpAddressType", + "path": "AppRunnerIpAddressType", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "AppRunnerIpAddressType/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "AppRunnerIpAddressType/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "AppRunnerIpAddressType/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "AppRunnerIpAddressType/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "AppRunnerIpAddressType/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.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": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts new file mode 100644 index 0000000000000..d1b9194f0f3cd --- /dev/null +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ip-address-type.ts @@ -0,0 +1,27 @@ +import * as cdk from 'aws-cdk-lib'; +import { IpAddressType, Service, Source } from '../lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'integ-apprunner-ip-address-type'); + +const service = new Service(stack, 'Service', { + serviceName: 'service', + source: Source.fromEcrPublic({ + imageConfiguration: { + port: 8000, + }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), + autoDeploymentsEnabled: false, + ipAddressType: IpAddressType.DUAL_STACK, +}); + +new cdk.CfnOutput(stack, 'URL', { value: `https://${service.serviceUrl}` }); + +new integ.IntegTest(app, 'AppRunnerIpAddressType', { + testCases: [stack], +}); + +app.synth(); \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts index d4ef80d552bd1..2168506b8ae66 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts @@ -1579,4 +1579,25 @@ test('timeout must be less than or equal to 20 in healthCheck', () => { }), }); }).toThrow('timeout must be between 1 and 20 seconds, got 21'); -}); \ No newline at end of file +}); + +test.each([apprunner.IpAddressType.IPV4, apprunner.IpAddressType.DUAL_STACK])('ipAddressType is set %s', (ipAddressType: apprunner.IpAddressType) => { + // GIVEN + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'demo-stack'); + // WHEN + new apprunner.Service(stack, 'DemoService', { + source: apprunner.Source.fromEcrPublic({ + imageConfiguration: { port: 8000 }, + imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', + }), + ipAddressType, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::AppRunner::Service', { + NetworkConfiguration: { + IpAddressType: ipAddressType, + }, + }); +}); From a6ab52cb1a9f944eb8f31e86aa96ec76355c41b1 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Thu, 30 May 2024 19:55:56 +0900 Subject: [PATCH 2/5] fix: test format --- packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts index bb5e1c66357dd..6843cd13a3bc5 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts @@ -1587,14 +1587,14 @@ test('create a service with a customer managed key)', () => { const app = new cdk.App(); const stack = new cdk.Stack(app, 'demo-stack'); const key = new kms.Key(stack, 'Key'); - + // WHEN new apprunner.Service(stack, 'DemoService', { source: apprunner.Source.fromEcrPublic({ imageConfiguration: { port: 8000 }, imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest', }), - kmsKey: key, + kmsKey: key, }); // THEN @@ -1610,7 +1610,7 @@ test.each([apprunner.IpAddressType.IPV4, apprunner.IpAddressType.DUAL_STACK])('i // GIVEN const app = new cdk.App(); const stack = new cdk.Stack(app, 'demo-stack'); - + // WHEN new apprunner.Service(stack, 'DemoService', { source: apprunner.Source.fromEcrPublic({ From e22bd3d625aa37f75ceaa65b22b3c1665318e5b4 Mon Sep 17 00:00:00 2001 From: maz Date: Thu, 30 May 2024 20:22:37 +0900 Subject: [PATCH 3/5] fix: format --- packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts index 2743d7a78c793..2178f94618080 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts @@ -723,7 +723,7 @@ export interface ServiceProps { * @default - Use an AWS managed key */ readonly kmsKey?: kms.IKey; - + /** * The IP address type for your incoming public network configuration. * From 06cca9dd79a34a4a31bc91078fdc654ce30f0a5f Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Sun, 2 Jun 2024 01:42:26 +0900 Subject: [PATCH 4/5] Update packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts Co-authored-by: Luca Pizzini --- packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts index 2178f94618080..412372e18bb90 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts @@ -727,7 +727,7 @@ export interface ServiceProps { /** * The IP address type for your incoming public network configuration. * - * @default - IPV4 + * @default - IpAddressType.IPV4 */ readonly ipAddressType?: IpAddressType; } From 31f31f5e9faa97456627e35ceb1a34e7011deb5e Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Sun, 2 Jun 2024 01:42:42 +0900 Subject: [PATCH 5/5] Update packages/@aws-cdk/aws-apprunner-alpha/README.md Co-authored-by: Luca Pizzini --- packages/@aws-cdk/aws-apprunner-alpha/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/@aws-cdk/aws-apprunner-alpha/README.md b/packages/@aws-cdk/aws-apprunner-alpha/README.md index 4c530cd9ae8b8..845a1eb34c447 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/README.md +++ b/packages/@aws-cdk/aws-apprunner-alpha/README.md @@ -194,6 +194,12 @@ new apprunner.Service(this, 'Service', { }); ``` +**Note**: Currently, App Runner supports dual stack for only Public endpoint. +Only IPv4 is supported for Private endpoint. +If you update a service that's using dual-stack Public endpoint to a Private endpoint, +your App Runner service will default to support only IPv4 for Private endpoint and fail +to receive traffic originating from IPv6 endpoint. + ## Secrets Manager To include environment variables integrated with AWS Secrets Manager, use the `environmentSecrets` attribute.