diff --git a/packages/@aws-cdk/aws-codebuild/lib/project.ts b/packages/@aws-cdk/aws-codebuild/lib/project.ts index 1e0950d5fd22a..597a816ca8fc1 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/project.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/project.ts @@ -929,11 +929,16 @@ export class Project extends ProjectBase { const resources = Object.values(props.environmentVariables) .filter(envVariable => envVariable.type === BuildEnvironmentVariableType.PARAMETER_STORE) + .map(envVariable => + // If the parameter name starts with / the resource name is not separated with a double '/' + // arn:aws:ssm:region:1111111111:parameter/PARAM_NAME + (envVariable.value as string).startsWith('/') + ? (envVariable.value as string).substr(1) + : envVariable.value) .map(envVariable => Stack.of(this).formatArn({ service: 'ssm', resource: 'parameter', - sep: ':', - resourceName: envVariable.value, + resourceName: envVariable, })); if (resources.length === 0) { diff --git a/packages/@aws-cdk/aws-codebuild/test/test.project.ts b/packages/@aws-cdk/aws-codebuild/test/test.project.ts index ba7b804d779f1..81a09bd3b96f8 100644 --- a/packages/@aws-cdk/aws-codebuild/test/test.project.ts +++ b/packages/@aws-cdk/aws-codebuild/test/test.project.ts @@ -796,7 +796,7 @@ export = { }, 'ENV_VAR2': { type: codebuild.BuildEnvironmentVariableType.PARAMETER_STORE, - value: '/params/param2', + value: 'params/param2', }, }, }); @@ -823,7 +823,7 @@ export = { { Ref: 'AWS::AccountId', }, - ':parameter:/params/param1', + ':parameter/params/param1', ], ], }, @@ -843,7 +843,7 @@ export = { { Ref: 'AWS::AccountId', }, - ':parameter:/params/param2', + ':parameter/params/param2', ], ], }],