Created
May 11, 2020 15:42
-
-
Save norbinsh/d245a3083935b3081069a2adc9efdeb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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