class PipelineDeployStackAction
Language | Type name |
---|---|
![]() | Amazon.CDK.AppDelivery.PipelineDeployStackAction |
![]() | software.amazon.awscdk.appdelivery.PipelineDeployStackAction |
![]() | aws_cdk.app_delivery.PipelineDeployStackAction |
![]() | @aws-cdk/app-delivery » PipelineDeployStackAction |
⚠️ Deprecated: undefined
Implements
IAction
A class to deploy a stack that is part of a CDK App, using CodePipeline.
This composite Action takes care of preparing and executing a CloudFormation ChangeSet.
It currently does not support stacks that make use of Asset
s, and
requires the deployed stack is in the same account and region where the
CodePipeline is hosted.
Example
import * as codebuild from '@aws-cdk/aws-codebuild';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import * as codepipeline_actions from '@aws-cdk/aws-codepipeline-actions';
import * as cdk from '@aws-cdk/core';
import * as cicd from '@aws-cdk/app-delivery';
import * as iam from '@aws-cdk/aws-iam';
class MyServiceStackA extends cdk.Stack {}
class MyServiceStackB extends cdk.Stack {}
const app = new cdk.App();
// We define a stack that contains the CodePipeline
const pipelineStack = new cdk.Stack(app, 'PipelineStack');
const pipeline = new codepipeline.Pipeline(pipelineStack, 'CodePipeline', {
// Mutating a CodePipeline can cause the currently propagating state to be
// "lost". Ensure we re-run the latest change through the pipeline after it's
// been mutated so we're sure the latest state is fully deployed through.
restartExecutionOnUpdate: true,
/* ... */
});
// Configure the CodePipeline source - where your CDK App's source code is hosted
const sourceOutput = new codepipeline.Artifact();
const source = new codepipeline_actions.GitHubSourceAction({
actionName: 'GitHub',
output: sourceOutput,
owner: 'myName',
repo: 'myRepo',
oauthToken: cdk.SecretValue.unsafePlainText('secret'),
});
pipeline.addStage({
stageName: 'source',
actions: [source],
});
const project = new codebuild.PipelineProject(pipelineStack, 'CodeBuild', {
/**
* Choose an environment configuration that meets your use case.
* For NodeJS, this might be:
*
* environment: {
* buildImage: codebuild.LinuxBuildImage.UBUNTU_14_04_NODEJS_10_1_0,
* },
*/
});
const synthesizedApp = new codepipeline.Artifact();
const buildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceOutput,
outputs: [synthesizedApp],
});
pipeline.addStage({
stageName: 'build',
actions: [buildAction],
});
// Optionally, self-update the pipeline stack
const selfUpdateStage = pipeline.addStage({ stageName: 'SelfUpdate' });
selfUpdateStage.addAction(new cicd.PipelineDeployStackAction({
stack: pipelineStack,
input: synthesizedApp,
adminPermissions: true,
}));
// Now add our service stacks
const deployStage = pipeline.addStage({ stageName: 'Deploy' });
const serviceStackA = new MyServiceStackA(app, 'ServiceStackA', { /* ... */ });
// Add actions to deploy the stacks in the deploy stage:
const deployServiceAAction = new cicd.PipelineDeployStackAction({
stack: serviceStackA,
input: synthesizedApp,
// See the note below for details about this option.
adminPermissions: false,
});
deployStage.addAction(deployServiceAAction);
// Add the necessary permissions for you service deploy action. This role is
// is passed to CloudFormation and needs the permissions necessary to deploy
// stack. Alternatively you can enable [Administrator](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html#jf_administrator) permissions above,
// users should understand the privileged nature of this role.
const myResourceArn = 'arn:partition:service:region:account-id:resource-id';
deployServiceAAction.addToDeploymentRolePolicy(new iam.PolicyStatement({
actions: ['service:SomeAction'],
resources: [myResourceArn],
// add more Action(s) and/or Resource(s) here, as needed
}));
const serviceStackB = new MyServiceStackB(app, 'ServiceStackB', { /* ... */ });
deployStage.addAction(new cicd.PipelineDeployStackAction({
stack: serviceStackB,
input: synthesizedApp,
createChangeSetRunOrder: 998,
adminPermissions: true, // no need to modify the role with admin
}));
Initializer
new PipelineDeployStackAction(props: PipelineDeployStackActionProps)
⚠️ Deprecated: undefined
Parameters
Properties
Name | Type | Description |
---|---|---|
action | Action | The simple properties of the Action, like its Owner, name, etc. |
deployment | IRole |
actionProperties
⚠️ Deprecated: undefined
Type:
Action
The simple properties of the Action, like its Owner, name, etc.
Note that this accessor will be called before the {@link bind} callback.
deploymentRole
⚠️ Deprecated: undefined
Type:
IRole
Methods
Name | Description |
---|---|
add | Add policy statements to the role deploying the stack. |
bind(scope, stage, options) | The callback invoked when this Action is added to a Pipeline. |
on | Creates an Event that will be triggered whenever the state of this Action changes. |
addToDeploymentRolePolicy(statement)
public addToDeploymentRolePolicy(statement: PolicyStatement): void
⚠️ Deprecated: undefined
Parameters
- statement
Policy
Statement
Add policy statements to the role deploying the stack.
This role is passed to CloudFormation and must have the IAM permissions
necessary to deploy the stack or you can grant this role adminPermissions
by using that option during creation. If you do not grant
adminPermissions
you need to identify the proper statements to add to
this role based on the CloudFormation Resources in your stack.
bind(scope, stage, options)
public bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfig
⚠️ Deprecated: undefined
Parameters
- scope
Construct
- stage
IStage
- options
Action
Bind Options
Returns
The callback invoked when this Action is added to a Pipeline.
onStateChange(name, target?, options?)
public onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Rule
⚠️ Deprecated: undefined
Parameters
- name
string
- target
IRule
Target - options
Rule
Props
Returns
Creates an Event that will be triggered whenever the state of this Action changes.