title: Passing parameters from parent stack to child stack in nested stack - Cloudformation
body: <p>I am trying to pass the paramters to internet facing elb using root. I have created a nested stack with a root.yml acting as root and vpc and elb are the child stack. I am trying to pass the parameters from root to elb.yml but it gives an error <code>Parameter values specified for a template which does not require them</code> while creating elb. The nested stack runs fine till vpc but when it gets to elb it gives an error</p>
  <p>Root.yml:</p>
  <pre class="lang-yaml prettyprint-override"><code>AWSTemplateFormatVersion: 2010-09-09
  Parameters:
    bucketname:
      Type: String
      Description: Path to the bucket
      Default: webserver
    bucketpath:
      Type: String
      Description: Path to the bucket
      Default: /nested-stack
  Resources:
    Vpcstack:
      Type: AWS::CloudFormation::Stack
      Properties:
        TemplateURL: !Sub &quot;https://${bucketname}.s3.us-east-2.amazonaws.com${bucketpath}/vpc1.yml&quot;
  
    elb:
      DependsOn: Vpcstack
      Type: AWS::CloudFormation::Stack
      Properties:
        TemplateURL: !Sub &quot;https://${bucketname}.s3.us-east-2.amazonaws.com${bucketpath}/internetfacing-elb.yml&quot;
        Parameters:
          SubnetA: !GetAtt Vpcstack.Outputs.SubnetA
          SubnetB: !GetAtt Vpcstack.Outputs.SubnetB
          VpcID: !GetAtt Vpcstack.Outputs.VpcID
  </code></pre>
  <p>Vpc stack:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  AWSTemplateFormatVersion: 2010-09-09
  Resources:
    VPC:
      Type: AWS::EC2::VPC
      Properties:
        CidrBlock: 11.0.0.0/16
        EnableDnsSupport: true
        EnableDnsHostnames: true
        InstanceTenancy: default
    InternetGateway:
      Type: AWS::EC2::InternetGateway
    VPCGatewayAttachment:
      Type: AWS::EC2::VPCGatewayAttachment
      Properties:
        VpcId: !Ref VPC
        InternetGatewayId: !Ref InternetGateway
    SubnetA:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-2a
        VpcId: !Ref VPC
        CidrBlock: 11.0.0.0/24
        MapPublicIpOnLaunch: true
    SubnetB:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-2b
        VpcId: !Ref VPC
        CidrBlock: 11.0.1.0/24
        MapPublicIpOnLaunch: true
    SubnetC:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-2a
        VpcId: !Ref VPC
        CidrBlock: 11.0.2.0/24
        MapPublicIpOnLaunch: false
    SubnetD:
      Type: AWS::EC2::Subnet
      Properties:
        AvailabilityZone: us-east-2b
        VpcId: !Ref VPC
        CidrBlock: 11.0.3.0/24
        MapPublicIpOnLaunch: false
    RouteTable:
      Type: AWS::EC2::RouteTable
      Properties:
        VpcId: !Ref VPC
    RouteTable2:
      Type: AWS::EC2::RouteTable
      Properties:
        VpcId: !Ref VPC
    InternetRoute:
      Type: AWS::EC2::Route
      DependsOn: VPCGatewayAttachment
      Properties:
        DestinationCidrBlock: 0.0.0.0/0
        GatewayId: !Ref InternetGateway
        RouteTableId: !Ref RouteTable
    SubnetARouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable
        SubnetId: !Ref SubnetA
    SubnetBRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable
        SubnetId: !Ref SubnetB
    SubnetCRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable2
        SubnetId: !Ref SubnetC
  
    SubnetDRouteTableAssociation:
      Type: AWS::EC2::SubnetRouteTableAssociation
      Properties:
        RouteTableId: !Ref RouteTable2
        SubnetId: !Ref SubnetD
    SecurityGroup:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupName: &quot;Internet Group&quot;
        GroupDescription: &quot;SSH traffic in, all traffic out.&quot;
        VpcId: !Ref VPC
        SecurityGroupIngress:
          - IpProtocol: tcp
            FromPort: &quot;22&quot;
            ToPort: &quot;22&quot;
            CidrIp: 0.0.0.0/0
        SecurityGroupEgress:
          - IpProtocol: -1
            CidrIp: 0.0.0.0/0
    NAT:
      Type: AWS::EC2::NatGateway
      Properties:
        AllocationId:
          Fn::GetAtt:
            - EIP
            - AllocationId
        SubnetId:
          Ref: SubnetA
        Tags:
          - Key: Name
            Value: ng-nat
    EIP:
      DependsOn: VPCGatewayAttachment
      Type: AWS::EC2::EIP
      Properties:
        Domain: VPC
    Route:
      Type: AWS::EC2::Route
      Properties:
        RouteTableId:
          Ref: RouteTable2
        DestinationCidrBlock: 0.0.0.0/0
        NatGatewayId:
          Ref: NAT
  Outputs:
    VpcID:
      Description: VPC id
      Value: !Ref VPC
      Export:
        Name: &quot;VpcID&quot;
    SubnetA:
      Description: public subnet
      Value: !Ref SubnetA
      Export:
        Name: &quot;SubnetA&quot;
    SubnetB:
      Description: public subnet 2
      Value: !Ref SubnetB
      Export:
        Name: &quot;SubnetB&quot;
    SubnetC:
      Description: priavte subnet
      Value: !Ref SubnetC
      Export:
        Name: &quot;SubnetC&quot;
    SubnetD:
      Description: private subnet 2
      Value: !Ref SubnetD
      Export:
        Name: &quot;SubnetD&quot;
  </code></pre>
  <p>internet facing elb:</p>
  <pre class="lang-yaml prettyprint-override"><code>---
  AWSTemplateFormatVersion: 2010-09-09
  Resources:
    elb:
      Type: AWS::EC2::SecurityGroup
      Properties:
        GroupName: sg-elb
        VpcId:
          Fn::ImportValue: &quot;VpcID&quot;
        SecurityGroupIngress:
          - IpProtocol: tcp
            FromPort: 22
            ToPort: 22
            CidrIp: 0.0.0.0/0
            Description: For traffic from Internet
          - IpProtocol: tcp
            FromPort: 80
            ToPort: 80
            CidrIp: 0.0.0.0/0
            Description: For traffic from Internet
        GroupDescription: Security Group for demo server
  
    MyLoadBalancer:
      Type: AWS::ElasticLoadBalancing::LoadBalancer
      Properties:
        Listeners:
          - LoadBalancerPort: &quot;80&quot;
            InstancePort: &quot;80&quot;
            Protocol: HTTP
        SecurityGroups:
          - !Ref elb
        LoadBalancerName: elb
        Subnets:
          - Fn::ImportValue: &quot;SubnetA&quot;
          - Fn::ImportValue: &quot;SubnetB&quot;
        HealthCheck:
          Target: HTTP:80/SamplePage.php
          HealthyThreshold: &quot;3&quot;
          UnhealthyThreshold: &quot;5&quot;
          Interval: &quot;30&quot;
          Timeout: &quot;5&quot;
  Outputs:
    ec2:
      Description: ec2
      Value: !Ref MyLoadBalancer
      Export:
        Name: &quot;MyLoadBalancer&quot;
    lgsg:
      Description: lg-sg
      Value: !GetAtt elb.GroupId
      Export:
        Name: &quot;lgsg&quot;
  </code></pre>