Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sourceAction = new S3SourceAction({
bucket: artifactsBucket,
bucketKey: `${stageName}_module_pipelines/module_source/${moduleName}.zip`,
output: sourceOutputArtifact,
trigger: S3Trigger.EVENTS, // Use EVENTS instead of POLL to avoid triggering. We won't set up CloudTrail for S3.
actionName: `${moduleName}_src`,
role: pipelineRole
})
this.addStage({
stageName: 'Source',
actions: [sourceAction]
})
const environmentVars = {
CROSS_ACCOUNT_ID: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.accountIds[stageName]}`
},
TARGET_REGION: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.defaultRegions[stageName]}`
},
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: stageName
},
MODULE_NAME: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: moduleName
},
...projectEnvironmentVars
}
trigger: S3Trigger.EVENTS, // Use EVENTS instead of POLL to avoid triggering. We won't set up CloudTrail for S3.
actionName: `${moduleName}_src`,
role: pipelineRole
})
this.addStage({
stageName: 'Source',
actions: [sourceAction]
})
const environmentVars = {
CROSS_ACCOUNT_ID: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.accountIds[stageName]}`
},
TARGET_REGION: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.defaultRegions[stageName]}`
},
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: stageName
},
MODULE_NAME: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: moduleName
},
...projectEnvironmentVars
}
const moduleBuildOutputArtifact = new Artifact()
const moduleBuildAction = new CodeBuildAction({
actionName: 'Build',
]
})
)
super(scope, id, {
projectName: `${props.stageName}E2ETest`,
environment: {
buildImage: LinuxBuildImage.STANDARD_2_0
},
environmentVariables: {
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: props.stageName
},
CROSS_ACCOUNT_ID: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.accountIds[props.stageName]}`
},
MAILOSAUR_API_KEY: {
type: BuildEnvironmentVariableType.PARAMETER_STORE,
value: '/test/mailosaur/apiKey'
},
MAILOSAUR_SERVER_ID: {
type: BuildEnvironmentVariableType.PARAMETER_STORE,
value: '/test/mailosaur/serverId'
}
},
buildSpec: BuildSpec.fromSourceFilename('e2e-tests/buildspec.yml'),
role,
...rest
})
}
actions: ['ssm:GetParameters'],
resources: [
`arn:aws:ssm:${config.region}:${
config.accountIds.cicd
}:parameter/test/*`
]
})
)
super(scope, id, {
projectName: `${props.stageName}IntegrationTest`,
environment: {
buildImage: LinuxBuildImage.STANDARD_2_0
},
environmentVariables: {
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: props.stageName
},
CROSS_ACCOUNT_ID: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.accountIds[props.stageName]}`
},
MAILOSAUR_API_KEY: {
type: BuildEnvironmentVariableType.PARAMETER_STORE,
value: '/test/mailosaur/apiKey'
},
MAILOSAUR_SERVER_ID: {
type: BuildEnvironmentVariableType.PARAMETER_STORE,
value: '/test/mailosaur/serverId'
}
},
buildSpec: BuildSpec.fromSourceFilename(
}:parameter/test/*`
]
})
)
super(scope, id, {
projectName: `${props.stageName}IntegrationTest`,
environment: {
buildImage: LinuxBuildImage.STANDARD_2_0
},
environmentVariables: {
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: props.stageName
},
CROSS_ACCOUNT_ID: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.accountIds[props.stageName]}`
},
MAILOSAUR_API_KEY: {
type: BuildEnvironmentVariableType.PARAMETER_STORE,
value: '/test/mailosaur/apiKey'
},
MAILOSAUR_SERVER_ID: {
type: BuildEnvironmentVariableType.PARAMETER_STORE,
value: '/test/mailosaur/serverId'
}
},
buildSpec: BuildSpec.fromSourceFilename(
'integration-tests/buildspec.yml'
),
role,
...rest
import config from '../../config'
import { BuildEnvironmentVariableType } from '@aws-cdk/aws-codebuild'
export const projectEnvironmentVars: any = {}
if (config.nsDomain) {
projectEnvironmentVars.SLIC_NS_DOMAIN = {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: config.nsDomain
}
} else {
projectEnvironmentVars.SITE_BUCKET_PREFIX = {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: config.siteBucketPrefix
}
}
pipelineRole
})
})
})
new SourceProject(this, 'sourceProject', {
projectName: 'SLICPipelineSource',
role: sourceCodeBuildRole,
bucket: artifactsBucket,
environmentVariables: {
ARTIFACTS_BUCKET_NAME: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: artifactsBucket.bucketName
},
ARTIFACTS_BUCKET_ARN: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: artifactsBucket.bucketArn
}
}
})
new PipelineDashboard(this, 'pipeline-dashboard')
}
}
moduleBuildProject,
moduleDeployProject,
moduleName,
stageName,
pipelineRole
})
})
})
new SourceProject(this, 'sourceProject', {
projectName: 'SLICPipelineSource',
role: sourceCodeBuildRole,
bucket: artifactsBucket,
environmentVariables: {
ARTIFACTS_BUCKET_NAME: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: artifactsBucket.bucketName
},
ARTIFACTS_BUCKET_ARN: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: artifactsBucket.bucketArn
}
}
})
new PipelineDashboard(this, 'pipeline-dashboard')
}
}
constructor(
scope: Construct,
id: string,
props: OrchestratorDeployProjectProps
) {
const { stageName, ...rest } = props
super(scope, id, {
projectName: `${props.stageName}DeployProject`,
environmentVariables: {
SLIC_STAGE: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: props.stageName
},
CROSS_ACCOUNT_ID: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: `${config.accountIds[props.stageName]}`
},
MODULE_NAMES: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: modules.moduleNames.join(' ')
}
},
buildSpec: BuildSpec.fromObject({
version: '0.2',
phases: {
build: {
commands: ['bash ./build-scripts/orchestrator-stage-deploy.sh']
artifacts: {
files: '**/*'
}
}),
source: buildSource,
environment: defaultEnvironment,
artifacts,
...rest,
environmentVariables: {
...rest.environmentVariables,
DEPLOYMENT_STATE_BUCKET: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: props.bucket.bucketName
},
DEPLOYMENT_STATE_KEY: {
type: BuildEnvironmentVariableType.PLAINTEXT,
value: DEPLOYMENT_STATE_KEY
}
}
})
}
}