cfstacks / stacks

Manage CloudFormation sanely with templates written in YAML
MIT License
42 stars 16 forks source link

Feature/diff #110

Closed alekna closed 6 years ago

alekna commented 6 years ago

Implements stacks diff. Fixes #38.

Compares compiled template and what's currently in CloudFormation and shows the difference.

Sample usage example:

$ stacks create --template buckets.yaml --env dev --property bucket_name_prefix=my-awesome-bucket --property buckets_count=1 -d
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "S3 buckets",
  "Resources": {
    "S3Bucket0": {
      "Properties": {
        "BucketName": "my-awesome-bucket0-us-east-1"
      },
      "Type": "AWS::S3::Bucket"
    }
  }
}
Name: s3-buckets
Tags: Env=dev, MD5Sum=0144615ae87286728cca830042baf53d
Template size: 240
$ stacks create --template buckets.yaml --env dev --property bucket_name_prefix=my-awesome-bucket
$ stacks list
s3-buckets  CREATE_COMPLETE
$ stacks diff --template buckets.yaml --env dev --property bucket_name_prefix=my-awesome-bucket --property buckets_count=2
  {
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "S3 buckets",
    "Resources": {
      "S3Bucket0": {
        "Properties": {
          "BucketName": "my-awesome-bucket0-us-east-1"
        },
        "Type": "AWS::S3::Bucket"
+     },
+     "S3Bucket1": {
+       "Properties": {
+         "BucketName": "my-awesome-bucket1-us-east-1"
+       },
+       "Type": "AWS::S3::Bucket"
      }
    }
  }
$ stacks update --template buckets.yaml --env dev --property bucket_name_prefix=my-awesome-bucket --property buckets_count=2 -f
2018-09-16 09:37:32.489000+01:00  UPDATE_IN_PROGRESS  AWS::CloudFormation::Stack  s3-buckets  User Initiated
2018-09-16 09:37:35.476000+01:00  CREATE_IN_PROGRESS  AWS::S3::Bucket  S3Bucket1
2018-09-16 09:37:36.058000+01:00  UPDATE_IN_PROGRESS  AWS::S3::Bucket  S3Bucket0
2018-09-16 09:37:36.147000+01:00  CREATE_IN_PROGRESS  AWS::S3::Bucket  S3Bucket1  Resource creation Initiated
2018-09-16 09:37:56.293000+01:00  UPDATE_COMPLETE  AWS::S3::Bucket  S3Bucket0
2018-09-16 09:37:56.577000+01:00  CREATE_COMPLETE  AWS::S3::Bucket  S3Bucket1
2018-09-16 09:37:58.553000+01:00  UPDATE_COMPLETE_CLEANUP_IN_PROGRESS  AWS::CloudFormation::Stack  s3-buckets
2018-09-16 09:37:59.449000+01:00  UPDATE_COMPLETE                      AWS::CloudFormation::Stack  s3-buckets
$ stacks diff --template buckets.yaml --env dev --property bucket_name_prefix=my-awesome-bucket --property buckets_count=2
$