Skip to content

Commit

Permalink
Revert "feat(aws-codedeploy): CodeDeploy Pipeline Action using the L2…
Browse files Browse the repository at this point in the history
… DeploymentGroup Construct. (#1085)"

This reverts commit 00ccb7f.
  • Loading branch information
Rico Huijbers committed Nov 6, 2018
1 parent 6e104ed commit 22e056b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 37 deletions.
49 changes: 36 additions & 13 deletions packages/@aws-cdk/aws-codedeploy/lib/pipeline-action.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import codepipeline = require('@aws-cdk/aws-codepipeline-api');
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/cdk');
import { ServerDeploymentGroupRef } from './deployment-group';

/**
* Construction properties of the {@link PipelineDeployAction CodeDeploy deploy CodePipeline Action}.
*/
export interface PipelineDeployActionProps extends codepipeline.CommonActionProps,
codepipeline.CommonActionConstructProps {
/**
* The CodeDeploy Deployment Group to deploy to.
* The name of the CodeDeploy application to deploy to.
*
* @note this will most likely be changed to a proper CodeDeploy AWS Construct reference
* once that functionality has been implemented for CodeDeploy
*/
applicationName: string;

/**
* The name of the CodeDeploy deployment group to deploy to.
*
* @note this will most likely be changed to a proper CodeDeploy AWS Construct reference
* once that functionality has been implemented for CodeDeploy
*/
deploymentGroup: ServerDeploymentGroupRef;
deploymentGroupName: string;

/**
* The source to use as input for deployment.
Expand All @@ -30,37 +40,50 @@ export class PipelineDeployAction extends codepipeline.DeployAction {
provider: 'CodeDeploy',
inputArtifact: props.inputArtifact,
configuration: {
ApplicationName: props.deploymentGroup.application.applicationName,
DeploymentGroupName: props.deploymentGroup.deploymentGroupName,
ApplicationName: props.applicationName,
DeploymentGroupName: props.deploymentGroupName,
},
});

// permissions, based on:
// https://docs.aws.amazon.com/codedeploy/latest/userguide/auth-and-access-control-permissions-reference.html

const applicationArn = cdk.ArnUtils.fromComponents({
service: 'codedeploy',
resource: 'application',
resourceName: props.applicationName,
sep: ':',
});
props.stage.pipeline.role.addToPolicy(new iam.PolicyStatement()
.addResource(props.deploymentGroup.application.applicationArn)
.addResource(applicationArn)
.addActions(
'codedeploy:GetApplicationRevision',
'codedeploy:RegisterApplicationRevision',
));

const deploymentGroupArn = cdk.ArnUtils.fromComponents({
service: 'codedeploy',
resource: 'deploymentgroup',
resourceName: `${props.applicationName}/${props.deploymentGroupName}`,
sep: ':',
});
props.stage.pipeline.role.addToPolicy(new iam.PolicyStatement()
.addResource(props.deploymentGroup.deploymentGroupArn)
.addResource(deploymentGroupArn)
.addActions(
'codedeploy:CreateDeployment',
'codedeploy:GetDeployment',
));

const deployConfigArn = cdk.ArnUtils.fromComponents({
service: 'codedeploy',
resource: 'deploymentconfig',
resourceName: '*',
sep: ':',
});
props.stage.pipeline.role.addToPolicy(new iam.PolicyStatement()
.addResource(props.deploymentGroup.deploymentConfig.deploymentConfigArn)
.addResource(deployConfigArn)
.addActions(
'codedeploy:GetDeploymentConfig',
));

// grant the ASG Role permissions to read from the Pipeline Bucket
for (const asg of props.deploymentGroup.autoScalingGroups || []) {
props.stage.pipeline.grantBucketRead(asg.role);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@
{
"Ref": "AWS::AccountId"
},
":application:",
{
"Ref": "CodeDeployApplicationE587C27C"
}
":application:IntegTestDeployApp"
]
]
}
Expand All @@ -205,14 +202,7 @@
{
"Ref": "AWS::AccountId"
},
":deploymentgroup:",
{
"Ref": "CodeDeployApplicationE587C27C"
},
"/",
{
"Ref": "CodeDeployGroup58220FC8"
}
":deploymentgroup:IntegTestDeployApp/IntegTestDeploymentGroup"
]
]
}
Expand All @@ -236,10 +226,7 @@
{
"Ref": "AWS::AccountId"
},
":deploymentconfig:",
{
"Ref": "CustomDeployConfig52EEBC13"
}
":deploymentconfig:*"
]
]
}
Expand Down Expand Up @@ -309,12 +296,8 @@
"Version": "1"
},
"Configuration": {
"ApplicationName": {
"Ref": "CodeDeployApplicationE587C27C"
},
"DeploymentGroupName": {
"Ref": "CodeDeployGroup58220FC8"
}
"ApplicationName": "IntegTestDeployApp",
"DeploymentGroupName": "IntegTestDeploymentGroup"
},
"InputArtifacts": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const deploymentConfig = new codedeploy.ServerDeploymentConfig(stack, 'CustomDep
minHealthyHostCount: 0,
});

const deploymentGroup = new codedeploy.ServerDeploymentGroup(stack, 'CodeDeployGroup', {
new codedeploy.ServerDeploymentGroup(stack, 'CodeDeployGroup', {
application,
deploymentGroupName: 'IntegTestDeploymentGroup',
deploymentConfig,
Expand All @@ -38,7 +38,8 @@ bucket.addToPipeline(sourceStage, 'S3Source', {
const deployStage = new codepipeline.Stage(stack, 'Deploy', { pipeline });
new codedeploy.PipelineDeployAction(stack, 'CodeDeploy', {
stage: deployStage,
deploymentGroup,
applicationName: 'IntegTestDeployApp',
deploymentGroupName: 'IntegTestDeploymentGroup',
});

app.run();

0 comments on commit 22e056b

Please sign in to comment.