diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/ecs-deploy-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/ecs-deploy-action.ts index 9f0df0fbb0066..771a1b8e3e448 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/ecs-deploy-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/ecs-deploy-action.ts @@ -1,7 +1,7 @@ import * as codedeploy from '@aws-cdk/aws-codedeploy'; import * as codepipeline from '@aws-cdk/aws-codepipeline'; import * as iam from '@aws-cdk/aws-iam'; -import { Construct } from '@aws-cdk/core'; +import { Construct, Lazy } from '@aws-cdk/core'; import { Action } from '../action'; /** @@ -177,17 +177,19 @@ export class CodeDeployEcsDeployAction extends Action { // the Action's Role needs to read from the Bucket to get artifacts options.bucket.grantRead(options.role); + const taskDefinitionTemplateArtifact = determineTaskDefinitionArtifact(this.actionProps); + const appSpecTemplateArtifact = determineAppSpecArtifact(this.actionProps); const actionConfig: codepipeline.ActionConfig = { configuration: { ApplicationName: this.actionProps.deploymentGroup.application.applicationName, DeploymentGroupName: this.actionProps.deploymentGroup.deploymentGroupName, - TaskDefinitionTemplateArtifact: determineTaskDefinitionArtifact(this.actionProps).artifactName, + TaskDefinitionTemplateArtifact: Lazy.stringValue({ produce: () => taskDefinitionTemplateArtifact.artifactName }), TaskDefinitionTemplatePath: this.actionProps.taskDefinitionTemplateFile ? this.actionProps.taskDefinitionTemplateFile.fileName : 'taskdef.json', - AppSpecTemplateArtifact: determineAppSpecArtifact(this.actionProps).artifactName, + AppSpecTemplateArtifact: Lazy.stringValue({ produce: () => appSpecTemplateArtifact.artifactName }), AppSpecTemplatePath: this.actionProps.appSpecTemplateFile ? this.actionProps.appSpecTemplateFile.fileName : 'appspec.yaml', @@ -197,7 +199,7 @@ export class CodeDeployEcsDeployAction extends Action { if (this.actionProps.containerImageInputs) { for (let i = 1; i <= this.actionProps.containerImageInputs.length; i++) { const imageInput = this.actionProps.containerImageInputs[i - 1]; - actionConfig.configuration[`Image${i}ArtifactName`] = imageInput.input.artifactName; + actionConfig.configuration[`Image${i}ArtifactName`] = Lazy.stringValue({ produce: () => imageInput.input.artifactName }); actionConfig.configuration[`Image${i}ContainerName`] = imageInput.taskDefinitionPlaceholder ? imageInput.taskDefinitionPlaceholder : 'IMAGE'; diff --git a/packages/@aws-cdk/aws-codepipeline-actions/test/codedeploy/test.ecs-deploy-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/codedeploy/test.ecs-deploy-action.ts index 7e160c0fed364..b75809ad8f515 100644 --- a/packages/@aws-cdk/aws-codepipeline-actions/test/codedeploy/test.ecs-deploy-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/codedeploy/test.ecs-deploy-action.ts @@ -146,13 +146,13 @@ export = { 'defaults task definition placeholder string'(test: Test) { const stack = new cdk.Stack(); const deploymentGroup = addEcsDeploymentGroup(stack); - const artifact1 = new codepipeline.Artifact('Artifact1'); - const artifact2 = new codepipeline.Artifact('Artifact2'); + const artifact1 = new codepipeline.Artifact(); + const artifact2 = new codepipeline.Artifact(); addCodeDeployECSCodePipeline(stack, { actionName: 'DeployToECS', deploymentGroup, - taskDefinitionTemplateFile: new codepipeline.ArtifactPath(artifact1, 'task-definition.json'), - appSpecTemplateFile: new codepipeline.ArtifactPath(artifact2, 'appspec-test.yaml'), + taskDefinitionTemplateFile: artifact1.atPath('task-definition.json'), + appSpecTemplateFile: artifact2.atPath('appspec-test.yaml'), containerImageInputs: [ { input: artifact1, @@ -172,21 +172,21 @@ export = { Configuration: { ApplicationName: 'MyApplication', DeploymentGroupName: 'MyDeploymentGroup', - TaskDefinitionTemplateArtifact: 'Artifact1', - AppSpecTemplateArtifact: 'Artifact2', + TaskDefinitionTemplateArtifact: 'Artifact_Source_GitHub', + AppSpecTemplateArtifact: 'Artifact_Source_GitHub2', TaskDefinitionTemplatePath: 'task-definition.json', AppSpecTemplatePath: 'appspec-test.yaml', - Image1ArtifactName: 'Artifact1', + Image1ArtifactName: 'Artifact_Source_GitHub', Image1ContainerName: 'IMAGE', - Image2ArtifactName: 'Artifact2', + Image2ArtifactName: 'Artifact_Source_GitHub2', Image2ContainerName: 'IMAGE', }, InputArtifacts: [ { - Name: 'Artifact1', + Name: 'Artifact_Source_GitHub', }, { - Name: 'Artifact2', + Name: 'Artifact_Source_GitHub2', }, ], },