Pass importer list in subnet

0

Hey,

I'm trying to import the already created subnets to pass as a parameter.

Example passing manually works:

 Subnets:
        - subnet-0000000000000000
        - subnet-1111111111111111
        - subnet-2222222222222222

But trying to use the importer to bring the subnets already exported from the error:

      Subnets:
        - !ImportValue vpc-subnet-private-1
        - !!mportValue vpc-subnet-private-2
        - !ImportValue vpc-subnet-private-3

I put it in the output to print the value of the exported variable and it shows the correct value.

Outputs:
  Subnets:
    Value: !ImportValue vpc-subnet-private-1

Error message that appears when I try to use the importer inside subnets:

There was an error creating this change set Module Resolution Failed: Unsupported keywords found in module fragment: Fn::ImportValue

Does anyone know how I might be fixing this?

Thanks!

asked 2 years ago305 views
1 Answer
0

Hello there,

I see you are facing issues while importing subnets using ImportValue.

To test the same, I ran the following templates in my test account and it worked smoothly.

Exporting the Subnet :

Resources:  
  VPC:
    Metadata:
      Comment: Stage speicfic VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsHostnames: 'true'
    Type: AWS::EC2::VPC
  mySubnet:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId:
        Ref: VPC
      CidrBlock: 10.0.0.0/18
      AvailabilityZone: "us-east-1a"
      Tags:
      - Key: stack
        Value: production
  subnet2:
    Type: AWS::EC2::Subnet
    Properties:
      VpcId:
        Ref: VPC
      CidrBlock: 10.0.64.0/18
      AvailabilityZone: "us-east-1b"
      

Outputs:
  VPC:
    Description: The VPC
    Export:
      Name: VPC
    Value: !Ref VPC
  subnet:
    Export:
      Name: subnet1
    Value: !Ref mySubnet
  subnet2:
    Export:
      Name: subnet2
    Value: !Ref subnet2

Importing the value :

Resources:  
  MyLoadBalancer:
      Type: AWS::ElasticLoadBalancing::LoadBalancer
      Properties:
        Subnets:
        - !ImportValue subnet1
        - !ImportValue subnet2
        CrossZone: true
        Listeners:
        - InstancePort: '80'
          InstanceProtocol: HTTP
          LoadBalancerPort: '80'
          Protocol: HTTP

I request you to test these samples in your account as well and check if they work. To find the root cause of the issue, can you please share the code snippet by removing any private information from it or raise a case with the support team so that we can look at the resources and guide you toward the solution.

AWS
SUPPORT ENGINEER
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions