diff --git a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts index 9d46156370d91..8f00645f1c061 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/lib/service.ts @@ -1073,6 +1073,7 @@ export class Service extends cdk.Resource { } const resource = new CfnService(this, 'Resource', { + serviceName: this.props.serviceName, instanceConfiguration: { cpu: this.props.cpu?.unit, memory: this.props.memory?.unit, diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.assets.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.assets.json index 48a63993e6eec..b7808023ed060 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.assets.json +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.assets.json @@ -1,7 +1,7 @@ { "version": "32.0.0", "files": { - "798d29f00c3d8f856bf85b7138c6e647084b39d095a48e9fe00157a314591215": { + "2181f59f2645e4bd58941c645d6d82a03c41c276ad3e6fd67609d6a733a7248e": { "source": { "path": "integ-apprunner-ecr-public.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "798d29f00c3d8f856bf85b7138c6e647084b39d095a48e9fe00157a314591215.json", + "objectKey": "2181f59f2645e4bd58941c645d6d82a03c41c276ad3e6fd67609d6a733a7248e.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.template.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.template.json index 67d76b4027d6e..0ad0186e6cd76 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.template.json +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/integ-apprunner-ecr-public.template.json @@ -19,7 +19,8 @@ "EgressConfiguration": { "EgressType": "DEFAULT" } - } + }, + "ServiceName": "service1" } } }, diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/manifest.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/manifest.json index bd8e2e634998f..0e044da302ecc 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/manifest.json @@ -17,7 +17,7 @@ "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}/798d29f00c3d8f856bf85b7138c6e647084b39d095a48e9fe00157a314591215.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/2181f59f2645e4bd58941c645d6d82a03c41c276ad3e6fd67609d6a733a7248e.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -36,7 +36,10 @@ "/integ-apprunner-ecr-public/Service1/Resource": [ { "type": "aws:cdk:logicalId", - "data": "Service1EDCC8134" + "data": "Service1EDCC8134", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_REPLACE" + ] } ], "/integ-apprunner-ecr-public/URL1": [ diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/tree.json b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/tree.json index e9048738bf35e..10cd57769cb02 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.js.snapshot/tree.json @@ -34,7 +34,8 @@ "egressConfiguration": { "egressType": "DEFAULT" } - } + }, + "serviceName": "service1" } }, "constructInfo": { @@ -56,38 +57,6 @@ "version": "0.0.0" } }, - "ServiceName": { - "id": "ServiceName", - "path": "integ-apprunner-ecr-public/ServiceName", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "ServiceId": { - "id": "ServiceId", - "path": "integ-apprunner-ecr-public/ServiceId", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "ServiceStatus": { - "id": "ServiceStatus", - "path": "integ-apprunner-ecr-public/ServiceStatus", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "ServiceArn": { - "id": "ServiceArn", - "path": "integ-apprunner-ecr-public/ServiceArn", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "integ-apprunner-ecr-public/BootstrapVersion", diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.ts index 211afe927f7bb..8248add7517ee 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/integ.service-ecr-public.ts @@ -7,6 +7,7 @@ const stack = new cdk.Stack(app, 'integ-apprunner-ecr-public'); // Scenario 1: Create the service from ECR public const service1 = new Service(stack, 'Service1', { + serviceName: 'service1', source: Source.fromEcrPublic({ imageConfiguration: { port: 8000, 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 6e0df962a7461..05f7254c5a0d2 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/service.test.ts @@ -1233,6 +1233,27 @@ test('autoDeploymentsEnabled flag is NOT set', () => { }); }); +test('serviceName is set', () => { + // GIVEN + const app = new cdk.App(); + const stack = new cdk.Stack(app, 'demo-stack'); + const serviceName = 'demo-service'; + // WHEN + new apprunner.Service(stack, 'DemoService', { + serviceName: serviceName, + source: apprunner.Source.fromGitHub({ + repositoryUrl: 'https://github.com/aws-containers/hello-app-runner', + branch: 'main', + configurationSource: apprunner.ConfigurationSourceType.REPOSITORY, + connection: apprunner.GitHubConnection.fromConnectionArn('MOCK'), + }), + }); + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::AppRunner::Service', { + ServiceName: serviceName, + }); +}); + testDeprecated('Using both environmentVariables and environment should throw an error', () => { const app = new cdk.App(); const stack = new cdk.Stack(app, 'demo-stack');