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

change diff to use CFN change sets instead of comparing template dicts #744

Merged
merged 10 commits into from
Feb 9, 2020
Merged

change diff to use CFN change sets instead of comparing template dicts #744

merged 10 commits into from
Feb 9, 2020

Conversation

ITProKyle
Copy link
Contributor

@ITProKyle ITProKyle commented Sep 12, 2019

Using CFN Change Sets will give a more accurate representation of what is being changed. Akin to terraform plan.

Usage

Interactive

A summary of changes is displayed for each stack (the same as stacker build). The user is prompted about displaying the full changeset before moving on.

$ stacker diff -i dev-us-west-2.env stacks.yaml
[2019-09-12T13:21:47] Using interactive AWS provider mode.
[2019-09-12T13:21:47] Diffing stacks: stacker-tf-state
[2019-09-12T13:21:49] example-stacker-tf-state changes:
Parameters Modified: BucketName
Replacements:
- Modify TerraformStateBucket (AWS::S3::Bucket)
Changes:
- Modify ManagementPolicy (AWS::IAM::ManagedPolicy)
Show full change set? [y/n] n

Default

The full change set is displayed. This example also showcases a stack (stacker-fake-resource) that is consuming the output of a previous stack (stacker-tf-state) resulting in an inferred change.

$ stacker diff dev-us-west-2.env stacks.yaml --region us-west-2 --replacements-only
[2019-09-12T13:30:16] Using default AWS provider mode
[2019-09-12T13:30:17] Diffing stacks: stacker-tf-state, stacker-fake-resource
[2019-09-12T13:30:19] example-stacker-tf-state full changeset:

--- Old Parameters
+++ New Parameters
******************
-BucketName = example-us-west-2-stackerdev
+BucketName = example-us-west-2-stackerdev-changed
 TableName = stacker-state-table

- ResourceChange:
    Action: Modify
    Details:
    - CausingEntity: TerraformStateBucket.Arn
      ChangeSource: ResourceAttribute
      Evaluation: Static
      Target:
        Attribute: Properties
        Name: PolicyDocument
        RequiresRecreation: Never
    LogicalResourceId: ManagementPolicy
    PhysicalResourceId: arn:aws:iam::************:policy/example-stacker-tf-state-ManagementPolicy-****
    Replacement: 'False'
    ResourceType: AWS::IAM::ManagedPolicy
    Scope:
    - Properties
  Type: Resource
- ResourceChange:
    Action: Modify
    Details:
    - ChangeSource: DirectModification
      Evaluation: Dynamic
      Target:
        Attribute: Properties
        Name: BucketName
        RequiresRecreation: Always
    - CausingEntity: BucketName
      ChangeSource: ParameterReference
      Evaluation: Static
      Target:
        Attribute: Properties
        Name: BucketName
        RequiresRecreation: Always
    LogicalResourceId: TerraformStateBucket
    PhysicalResourceId: example-us-west-2-stackerdev
    Replacement: 'True'
    ResourceType: AWS::S3::Bucket
    Scope:
    - Properties
  Type: Resource

[2019-09-12T13:30:19] stacker-tf-state: complete
[2019-09-12T13:30:22] example-stacker-fake-resource full changeset:

--- Old Parameters
+++ New Parameters
******************
-TestParameter = example-us-west-2-stackerdev
+TestParameter = <inferred-change: example-stacker-tf-state.TerraformStateBucketName={'Ref': 'TerraformStateBucket'}>

- ResourceChange:
    Action: Modify
    Details:
    - ChangeSource: DirectModification
      Evaluation: Dynamic
      Target:
        Attribute: Properties
        Name: BucketName
        RequiresRecreation: Always
    - CausingEntity: TestParameter
      ChangeSource: ParameterReference
      Evaluation: Static
      Target:
        Attribute: Properties
        Name: BucketName
        RequiresRecreation: Always
    LogicalResourceId: TestBucket
    PhysicalResourceId: example-us-west-2-stackerdev-x
    Replacement: 'True'
    ResourceType: AWS::S3::Bucket
    Scope:
    - Properties
  Type: Resource

@troyready troyready self-requested a review September 16, 2019 18:44
@quick-refs
Copy link

Has this been released? or any plan on releasing it

Copy link
Member

@phobologic phobologic left a comment

Choose a reason for hiding this comment

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

Love this- thank you, merging!

@phobologic phobologic merged commit 106ddf3 into cloudtools:master Feb 9, 2020
@ITProKyle ITProKyle deleted the diff-use-changeset branch February 9, 2020 22:26
deepmap-marcinr pushed a commit to deepmap/stacker that referenced this pull request Feb 24, 2020
deepmap-marcinr pushed a commit to deepmap/stacker that referenced this pull request Mar 25, 2020
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.

4 participants