aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Add AWS::CloudFormation::Stackset resource to cloudformation package command

Open ConnorKirk opened this issue 5 years ago • 13 comments

Issue #, if available: #5590

Description of changes: This PR enables the aws cloudformation package command to package the AWS::CloudFormation::Stackset resource.

It defines the CloudFormationStacksetResource class in artifact_exporter.py. This is an extension of the CloudFormationStackResource class.

I have also updated the docs.

Before this is merged, I debated whether a test should be added to tests/unit/customizations/cloudformation/test_artifact_exporter.py. I would appreciate some guidance on whether this is necessary.

Here is an example snippet of the template, and output after the packaging command

# template.yaml
MainStackSet:
    Type: AWS::CloudFormation::StackSet
    Properties:
      StackSetName: example-stackset
      PermissionModel: SELF_MANAGED
      TemplateURL: ./main.yaml
      Capabilities:
          - CAPABILITY_IAM
      StackInstancesGroup: 
        - Regions:
            - us-east-1
          DeploymentTargets:
            Accounts:
              - !Ref AWS::AccountId
#packaged.yaml
MainStackSet:
    Type: AWS::CloudFormation::StackSet
    Properties:
      StackSetName: example-stackset
      PermissionModel: SELF_MANAGED
      TemplateURL: https://s3.eu-west-2.amazonaws.com/example-bucket/stackset-test/9a8c1dca11fcd0938d8eb3b6850e9d9c.template
      Capabilities:
      - CAPABILITY_IAM
      StackInstancesGroup:
      - Regions:
        - us-east-1
        DeploymentTargets:
          Accounts:
          - Ref: AWS::AccountId

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ConnorKirk avatar Sep 30 '20 11:09 ConnorKirk

Codecov Report

Merging #5591 into develop will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #5591   +/-   ##
========================================
  Coverage    92.51%   92.51%           
========================================
  Files          196      196           
  Lines        15890    15893    +3     
========================================
+ Hits         14701    14704    +3     
  Misses        1189     1189           
Impacted Files Coverage Δ
...customizations/cloudformation/artifact_exporter.py 98.67% <100.00%> (+0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dabd57b...4fe7c72. Read the comment docs.

codecov-commenter avatar Sep 30 '20 11:09 codecov-commenter

I confirm that it works!

The only issue I encountered with this solution, is that it potentially packs nested stacks inside the StackSet which is not supported by the CloudFormation itself:

Invalid request provided: Nested AWS::CloudFormation::Stack is not supported in AWS::CloudFormation::StackSet

CloudFormation provides a good error message, so it seems to be not a big deal that user discovers it only on the deployment step. Usage of CloudFormationStackResource parent class still seems to be justified, because nested stack may contain Lambdas and other uploadable dependencies.

dbolotin avatar Oct 04 '20 23:10 dbolotin

Codecov Report

Merging #5591 (bf43fed) into develop (dabd57b) will decrease coverage by 0.52%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5591      +/-   ##
===========================================
- Coverage    92.51%   91.98%   -0.53%     
===========================================
  Files          196      196              
  Lines        15890    15902      +12     
===========================================
- Hits         14701    14628      -73     
- Misses        1189     1274      +85     
Impacted Files Coverage Δ
...customizations/cloudformation/artifact_exporter.py 98.00% <100.00%> (-0.66%) :arrow_down:
awscli/customizations/putmetricdata.py 88.88% <0.00%> (-11.12%) :arrow_down:
awscli/customizations/ec2/addcount.py 84.00% <0.00%> (-10.00%) :arrow_down:
awscli/customizations/streamingoutputarg.py 89.65% <0.00%> (-8.63%) :arrow_down:
awscli/customizations/ec2/decryptpassword.py 79.36% <0.00%> (-6.35%) :arrow_down:
awscli/customizations/s3/utils.py 92.76% <0.00%> (-5.35%) :arrow_down:
awscli/customizations/s3/filegenerator.py 94.05% <0.00%> (-4.87%) :arrow_down:
awscli/customizations/commands.py 94.75% <0.00%> (-4.81%) :arrow_down:
awscli/customizations/arguments.py 95.23% <0.00%> (-4.77%) :arrow_down:
awscli/customizations/paginate.py 93.93% <0.00%> (-3.79%) :arrow_down:
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dabd57b...e64cb85. Read the comment docs.

codecov-io avatar Nov 24 '20 10:11 codecov-io

Any way this can get merged? The related issue has 13 👍 and this was originally approved in Oct 2020?

atheiman avatar Feb 11 '22 14:02 atheiman

Codecov Report

Merging #5591 (31757ea) into develop (23e4b4f) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff            @@
##           develop    #5591   +/-   ##
========================================
  Coverage    92.87%   92.87%           
========================================
  Files          204      204           
  Lines        16329    16332    +3     
========================================
+ Hits         15166    15169    +3     
  Misses        1163     1163           
Impacted Files Coverage Δ
...customizations/cloudformation/artifact_exporter.py 98.67% <100.00%> (+0.01%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 23e4b4f...31757ea. Read the comment docs.

codecov-commenter avatar May 31 '22 21:05 codecov-commenter

Apologies for the delayed response. I've rebased the PR branch onto the latest develop branch to take care of the existing merge conflicts and run the latest CI tests.

Our team just put out a contribution guide detailing improvements to the contribution process. This PR looks like it falls under the "Ready for Review" stage. At the moment, our team is working through the PR/Issue backlog to determine where each PR belongs in our updated contribution process. After that, a maintainer will take a closer look at this PR.

justindho avatar May 31 '22 22:05 justindho

Hi guys, it's been 2 years already. Is there any chances the MR will be deployed? Thank you

thanhthai3010 avatar Oct 03 '22 09:10 thanhthai3010

@thanhthai3010 fyi the packaging works fine for this usecase via sam-cli if you're looking for a "workaround" ;)

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html

steenda avatar Mar 29 '23 08:03 steenda

@thanhthai3010 fyi the packaging works fine for this usecase via sam-cli if you're looking for a "workaround" ;)

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-package.html

hi @steenda, thank you so much for replying, let me check the information.

thanhthai3010 avatar Mar 30 '23 04:03 thanhthai3010

Hi @ConnorKirk, thanks for this PR and for your patience on hearing back. After bringing this up to discuss with the team, we've decided to set this PR as a draft and continue tracking this feature. We'll also be leaving the issue (https://github.com/aws/aws-cli/issues/5590) open for tracking. As a workaround, I'd recommend taking a look at the SAM CLI, which does have support for this resource. Thanks!

RyanFitzSimmonsAK avatar Sep 26 '23 20:09 RyanFitzSimmonsAK

Thanks Ryan 🙂

Are there changes required, or just not able to proceed with it at the moment?

I am using the SAM CLI as a workaround, but some customers can't/don't use SAM CLI. This feature (and parity for the rest of the aws cloudformation package resources would be useful for them.

ConnorKirk avatar Sep 27 '23 06:09 ConnorKirk

No changes required at the moment.

RyanFitzSimmonsAK avatar Sep 27 '23 17:09 RyanFitzSimmonsAK

@RyanFitzSimmonsAK can we get this PR merged, the suggested workarounds are not sufficient?

jhonkan avatar Sep 04 '24 07:09 jhonkan