Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CloudFormation actions in CodePipeline #509

Closed
wants to merge 1 commit into from

Conversation

mindstorms6
Copy link
Contributor


Author's note: This work mostly belongs to Max Hall (@hallmaxw)
It was at some point commented out during a refactor - this is just adding it back.
Most of the credit should go to him.

Anywho - this adds the ability for customers to use CloudForamtion actions in CodePipeline.
This follows the same pattern as previous CodePipeline actions by making it it's own package.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

---
Author's note: This work mostly belongs to Max Hall (@hallmaxw)
It was at some point commented out during a refactor - this is just adding it back.
Most of the credit should go to him.
---

Anywho - this adds the ability for customers to use CloudForamtion actions in CodePipeline.
This follows the same pattern as previous CodePipeline actions by making it it's own package.
@mindstorms6 mindstorms6 requested review from eladb and hallmaxw August 5, 2018 21:58
import { ArtifactPath, Pipeline, Stage } from '@aws-cdk/aws-codepipeline';
import { Role } from '@aws-cdk/aws-iam';
import { PolicyStatement, ServicePrincipal } from '@aws-cdk/cdk';
import { CreateReplaceChangeSet, ExecuteChangeSet } from '../lib/pipeline-action';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This is not how users would use this module.
  • I don't think there's a need to explicitly call out all the imports here.
  • Also, we have been standardizing around namespaced imports: import cdk = require('@aws-cdk/cdk'), etc.

stackName,
changeSetName,
roleArn: changeSetExecRole.roleArn,
templatePath: new ArtifactPath(source.artifact, 'some_template.yaml'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aspect is probably worth a bit of explaining in the README. Who put some_template.yaml there? Try to think from a user's perspective what would they need to quickly make this work for their use case.

@@ -0,0 +1,50 @@
## AWS CodePipline Actions for AWS CloudFormation

This module contains an Action that allows you to use CloudFormation actions from CodePipeline.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README requires a bit more work 😄 Where are the gifs?

Also, I think it will be useful to list all the action types and when would someone want to use them

import { ArtifactPath, DeployAction, Stage, } from '@aws-cdk/aws-codepipeline';
import { RoleArn } from '@aws-cdk/aws-iam';

export enum CloudFormationCapabilities {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdocs

NamedIAM = 'CAPABILITY_NAMED_IAM'
}

export interface CloudFormationCommonOptions {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing @default descriptions

}

/**
* Executes a change set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some docs about when would someone want to use this


/**
* The path to the template to pass to CloudFormation during the change set operation.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide a usage example here

* The arn of the IAM service role that AWS CloudFormation assumes
* when it operates on resources in the specified stack.
*/
roleArn: RoleArn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Role and optional (default should be to auto-create a role by the construct)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky. Normally when we follow this pattern, we autocreate a Role with the right permissions.

In this case though, the "right permissions" are *:*, because there's no telling what the CloudFormation might do. Except... autocreating a role that has *:* feels risky. So the better solution might be to punt it to the consumer, and have them knowingly opt in.

In the same vein, I wonder if we should default the IAM capabilities to... you know... work. Everyone's going to want this and hence specify the IAM capabilities. Should we make people opt out to improve convenience in the 99% case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could still create a role with no statements and require that the user explicitly call addToRolePolicy with whatever permissions they want.

As sugar, we can implement a props flag such as adminRights: boolean which will auto-add the "/" and set the IAM capabilities to all

* The arn of the IAM service role that AWS CloudFormation assumes
* when it operates on resources in the specified stack.
*/
roleArn: RoleArn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same (Role and optional)

* The arn of the IAM service role that AWS CloudFormation assumes
* when it operates on resources in the specified stack.
*/
roleArn: RoleArn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 8, 2018

Superseded by #525

@rix0rrr rix0rrr closed this Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants