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

AWS::CloudFormation::StackSet - return instance Outputs #2216

Open
mo7ty opened this issue Dec 14, 2024 · 1 comment
Open

AWS::CloudFormation::StackSet - return instance Outputs #2216

mo7ty opened this issue Dec 14, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mo7ty
Copy link

mo7ty commented Dec 14, 2024

Name of the resource

AWS::CloudFormation::StackSet

Resource name

No response

Description

It would be a great help for the AWS community using CloudFormation templates for IaC to have AWS::CloudFormation::StackSet returning not just its logical ID, but also be able to return its instance Outputs.

Usage template sample:

WAFStackSet:
  Type: AWS::CloudFormation::StackSet
  Properties:
    StackSetName: WAFStackSet
    Description: CloudFormation StackSet used to provision WAF resources
    PermissionModel: SELF_MANAGED
    StackInstancesGroup:
      - DeploymentTargets:
          Accounts: [!Ref "AWS::AccountId"]
        Regions: [us-east-1]
    TemplateBody: |
      AWSTemplateFormatVersion: 2010-09-09
      Description: WAF Stack
      Resources:
        WebACL:
          Type: AWS::WAFv2::WebACL
          Properties:
          ...
      Outputs:
        WAFWebACLId:
          Value: !GetAtt WebACL.Id

CloudFrontDistribution:
  Type: AWS::CloudFront::Distribution
  Properties:
    DistributionConfig:
      WebACLId: !GetAtt WAFStackSet.Outputs.WAFWebACLId
      ...

With this improvement being a solution to overcome limitations like:

Because there are also missing:

Additional references from re:Post that would benefit with this:

Other Details

No response

@mo7ty mo7ty added the enhancement New feature or request label Dec 14, 2024
@mo7ty mo7ty changed the title [Resource Type] - [Enhancement] - AWS::CloudFormation::StackSet to return Outputs AWS::CloudFormation::StackSet - return Outputs Dec 14, 2024
@mo7ty
Copy link
Author

mo7ty commented Dec 15, 2024

Using Boto3 CloudFormation Client is possible to get AWS::CloudFormation::StackSet outputs:

import boto3

# stack_set_name = !GetAtt WAFStackSet.Outputs.WAFWebACLId

cloudformation = boto3.client('cloudformation')
response = cloudformation.list_stack_instances(StackSetName=stack_set_name)
region = response["Summaries"][0]["Region"]
stack_id = response["Summaries"][0]["StackId"]

cloudformation = boto3.client('cloudformation', region_name=region)
response = cloudformation.describe_stacks(StackName=stack_id)
outputs = response["Stacks"][0]["Outputs"]

result = {output["OutputKey"]: output["OutputValue"] for output in outputs}
print("result={}".format(result))

@mo7ty mo7ty changed the title AWS::CloudFormation::StackSet - return Outputs AWS::CloudFormation::StackSet - return instance Outputs Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant