โ† Back to list
armanzeroeight

stack-designer

by armanzeroeight

๐Ÿš€ A collection of Claude subagents, skills, rules, guides, and blueprints for Developers, Engineers, and Creators. | Covering programming languages, DevOps, Cloud, and beyond.

โญ 20๐Ÿด 4๐Ÿ“… Jan 18, 2026

SKILL.md


name: stack-designer description: Designs CloudFormation stack structure, nested stacks, and resource organization. Use when designing CloudFormation infrastructure, organizing resources into stacks, or planning nested stack hierarchies.

Stack Designer

Quick Start

Design well-organized CloudFormation stacks with proper resource grouping, parameters, outputs, and cross-stack references.

Instructions

Step 1: Identify stack boundaries

Determine how to organize resources into stacks:

By lifecycle:

  • Resources that change together should be in the same stack
  • Separate frequently updated resources from stable infrastructure
  • Group by deployment frequency

By ownership:

  • Network stack (VPC, subnets, route tables)
  • Security stack (security groups, IAM roles)
  • Application stack (EC2, ECS, Lambda)
  • Data stack (RDS, DynamoDB, S3)

By environment:

  • Separate dev, staging, production stacks
  • Use parameters for environment-specific values
  • Share common resources via cross-stack references

Step 2: Design stack structure

Simple stack (single template):

AWSTemplateFormatVersion: '2010-09-09'
Description: Simple web application stack

Parameters:
  EnvironmentName:
    Type: String
    Default: dev
    AllowedValues: [dev, staging, prod]
  
  InstanceType:
    Type: String
    Default: t3.micro
    AllowedValues: [t3.micro, t3.small, t3.medium]

Resources:
  WebServer:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: !Ref InstanceType
      ImageId: !Sub '{{resolve:ssm:/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2}}'
      Tags:
        - Key: Environment
          Value: !Ref EnvironmentName

Outputs:
  InstanceId:
    Description: EC2 instance ID
    Value: !Ref WebServer
    Export:
      Name: !Sub '${AWS::StackName}-InstanceId'

Multi-stack architecture:

Root Stack
โ”œโ”€โ”€ Network Stack (VPC, subnets)
โ”œโ”€โ”€ Security Stack (security groups, IAM)
โ”œโ”€โ”€ Database Stack (RDS)
โ””โ”€โ”€ Application Stack (EC2, ALB)

Step 3: Define parameters

Parameter best practices:

Parameters:
  # Use descriptive names
  DatabaseInstanceClass:
    Type: String
    Default: db.t3.micro
    AllowedValues:
      - db.t3.micro
      - db.t3.small
      - db.t3.medium
    Description: RDS instance class
  
  # Validate input
  DatabaseName:
    Type: String
    MinLength: 1
    MaxLength: 64
    AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
    ConstraintDescription: Must begin with letter, contain only alphanumeric
  
  # Use AWS-specific types
  VpcId:
    Type: AWS::EC2::VPC::Id
    Description: VPC for resources
  
  SubnetIds:
    Type: List<AWS::EC2::Subnet::Id>
    Description: Subnets for resources
  
  # Sensitive values from SSM
  DatabasePassword:
    Type: AWS::SSM::Parameter::Value<String>
    Default: /myapp/database/password
    NoEcho: true

Step 4: Configure outputs

Output best practices:

Outputs:
  # Export for cross-stack references
  VpcId:
    Description: VPC ID
    Value: !Ref VPC
    Export:
      Name: !Sub '${AWS::StackName}-VpcId'
  
  # Multiple values
  PrivateSubnetIds:
    Description: Private subnet IDs
    Value: !Join [',', [!Ref PrivateSubnet1, !Ref PrivateSubnet2]]
    Export:
      Name: !Sub '${AWS::StackName}-PrivateSubnets'
  
  # Resource attributes
  LoadBalancerDNS:
    Description: ALB DNS name
    Value: !GetAtt ApplicationLoadBalancer.DNSName
  
  # Conditional outputs
  DatabaseEndpoint:
    Condition: CreateDatabase
    Description: RDS endpoint
    Value: !GetAtt Database.Endpoint.Address

Step 5: Implement cross-stack references

Exporting from one stack:

Outputs:
  SecurityGroupId:
    Value: !Ref WebSecurityGroup
    Export:
      Name: !Sub '${AWS::StackName}-SecurityGroupId'

Importing in another stack:

Resources:
  WebServer:
    Type: AWS::EC2::Instance
    Properties:
      SecurityGroupIds:
        - !ImportValue NetworkStack-SecurityGroupId

Nested Stacks

Parent stack:

Resources:
  NetworkStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://s3.amazonaws.com/mybucket/network.yaml
      Parameters:
        EnvironmentName: !Ref EnvironmentName
      Tags:
        - Key: Name
          Value: Network
  
  ApplicationStack:
    Type: AWS::CloudFormation::Stack
    DependsOn: NetworkStack
    Properties:
      TemplateURL: https://s3.amazonaws.com/mybucket/application.yaml
      Parameters:
        VpcId: !GetAtt NetworkStack.Outputs.VpcId
        SubnetIds: !GetAtt NetworkStack.Outputs.SubnetIds

Benefits:

  • Reusable templates
  • Logical organization
  • Independent updates
  • Overcome template size limits

Common Patterns

Pattern 1: Environment-specific stacks

# Use parameters for environment differences
Parameters:
  Environment:
    Type: String
    AllowedValues: [dev, staging, prod]

Mappings:
  EnvironmentConfig:
    dev:
      InstanceType: t3.micro
      MinSize: 1
      MaxSize: 2
    staging:
      InstanceType: t3.small
      MinSize: 2
      MaxSize: 4
    prod:
      InstanceType: t3.medium
      MinSize: 3
      MaxSize: 10

Resources:
  AutoScalingGroup:
    Type: AWS::AutoScaling::AutoScalingGroup
    Properties:
      MinSize: !FindInMap [EnvironmentConfig, !Ref Environment, MinSize]
      MaxSize: !FindInMap [EnvironmentConfig, !Ref Environment, MaxSize]
      LaunchTemplate:
        LaunchTemplateId: !Ref LaunchTemplate
        Version: !GetAtt LaunchTemplate.LatestVersionNumber

Pattern 2: Conditional resources

Parameters:
  CreateDatabase:
    Type: String
    Default: 'true'
    AllowedValues: ['true', 'false']

Conditions:
  ShouldCreateDatabase: !Equals [!Ref CreateDatabase, 'true']
  IsProduction: !Equals [!Ref Environment, 'prod']

Resources:
  Database:
    Type: AWS::RDS::DBInstance
    Condition: ShouldCreateDatabase
    Properties:
      DBInstanceClass: !If [IsProduction, db.t3.medium, db.t3.micro]
      MultiAZ: !If [IsProduction, true, false]

Pattern 3: Resource dependencies

Resources:
  # Explicit dependency
  WebServer:
    Type: AWS::EC2::Instance
    DependsOn: DatabaseInstance
    Properties:
      # ...
  
  # Implicit dependency via Ref
  SecurityGroupIngress:
    Type: AWS::EC2::SecurityGroupIngress
    Properties:
      GroupId: !Ref SecurityGroup
      SourceSecurityGroupId: !Ref LoadBalancerSecurityGroup

Stack Organization Strategies

Strategy 1: Layered architecture

Foundation Layer (rarely changes)
โ”œโ”€โ”€ Network Stack (VPC, subnets, NAT)
โ””โ”€โ”€ Security Stack (IAM roles, KMS keys)

Platform Layer (occasional changes)
โ”œโ”€โ”€ Database Stack (RDS, ElastiCache)
โ””โ”€โ”€ Storage Stack (S3, EFS)

Application Layer (frequent changes)
โ”œโ”€โ”€ Compute Stack (EC2, ECS, Lambda)
โ””โ”€โ”€ API Stack (API Gateway, ALB)

Strategy 2: Service-oriented

Per-service stacks:
โ”œโ”€โ”€ User Service Stack
โ”œโ”€โ”€ Order Service Stack
โ”œโ”€โ”€ Payment Service Stack
โ””โ”€โ”€ Shared Infrastructure Stack

Strategy 3: Environment isolation

Per-environment stacks:
โ”œโ”€โ”€ Dev Environment
โ”‚   โ”œโ”€โ”€ Network
โ”‚   โ”œโ”€โ”€ Application
โ”‚   โ””โ”€โ”€ Data
โ”œโ”€โ”€ Staging Environment
โ”‚   โ”œโ”€โ”€ Network
โ”‚   โ”œโ”€โ”€ Application
โ”‚   โ””โ”€โ”€ Data
โ””โ”€โ”€ Production Environment
    โ”œโ”€โ”€ Network
    โ”œโ”€โ”€ Application
    โ””โ”€โ”€ Data

Advanced

For detailed information, see:

  • Nested Stacks - Nested stack patterns and best practices
  • Parameters - Parameter design and validation strategies
  • Outputs - Output design and cross-stack references

Score

Total Score

70/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โœ“LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+10
โœ“่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

+10
โ—‹ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

0/15
โœ“ๆœ€่ฟ‘ใฎๆดปๅ‹•

1ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐ

+10
โ—‹ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โ—‹่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

0/5
โœ“ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5

Reviews

๐Ÿ’ฌ

Reviews coming soon