Skip to content

Instantly share code, notes, and snippets.

@norbinsh
Created May 11, 2020 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norbinsh/d245a3083935b3081069a2adc9efdeb1 to your computer and use it in GitHub Desktop.
Save norbinsh/d245a3083935b3081069a2adc9efdeb1 to your computer and use it in GitHub Desktop.
// create codebuild project
const codeBuildProject = new codebuild.Project(
scope,
`${props.environment}-${props.pipelineNamePrefix}-validation`,
{
projectName: `${props.environment}-${props.pipelineNamePrefix}-validation`,
source: githubSource,
buildSpec: codebuild.BuildSpec.fromSourceFilename('buildspec_pull_request.yml'),
environment: {
buildImage: codebuild.LinuxBuildImage.AMAZON_LINUX_2,
privileged: true,
environmentVariables: buildEnvVariables,
computeType: props.computeType,
},
}
);
// Attach permissions to codebuild role
codeBuildProject.addToRolePolicy(
new PolicyStatement({
effect: Effect.ALLOW,
resources: [props.deploymentRoleArn],
actions: ['sts:AssumeRole'],
})
);
// attach a separated policy that allows getParam from parameter store.
codeBuildProject.addToRolePolicy(
new PolicyStatement({
effect: Effect.ALLOW,
resources: ['*'],
actions: [
'ssm:GetParameterHistory',
'ssm:GetParametersByPath',
'ssm:GetParameters',
'ssm:GetParameter',
'ssm:DescribeParameters',
],
})
);
return codeBuildProject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment