Skip to content

Instantly share code, notes, and snippets.

@kronis
Created September 8, 2022 20:48
Show Gist options
  • Save kronis/7e9ea920799d688de5cfda5ea7f65982 to your computer and use it in GitHub Desktop.
Save kronis/7e9ea920799d688de5cfda5ea7f65982 to your computer and use it in GitHub Desktop.
AWS CDK CodePipeLines with private NPM repo
const GHSecret = Secret.fromSecretNameV2(scope, 'GHSecret', 'github/read_registry');
const codeStarArn = '';
const input = CodePipelineSource.connection(props.repositoryName, props.repositoryBranch, {
connectionArn: codeStarArn
});
return new CodePipeline(scope, `Pipeline`, {
synthCodeBuildDefaults: {
buildEnvironment: {
environmentVariables: {
GITHUB_ACCESS_TOKEN: {
value: `${GHSecret.secretName}:GITHUB_ACCESS_TOKEN`,
type: BuildEnvironmentVariableType.SECRETS_MANAGER,
},
},
},
},
codeBuildDefaults: {
buildEnvironment: {
environmentVariables: {
GITHUB_ACCESS_TOKEN: {
value: `${GHSecret.secretName}:GITHUB_ACCESS_TOKEN`,
type: BuildEnvironmentVariableType.SECRETS_MANAGER,
},
},
},
},
synth: new ShellStep('Synth', {
input,
commands: [
'mv -f .npmrc_ci .npmrc 2>/dev/null; true',
'npm ci',
'npm run build',
'npx cdk synth',
],
}),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment