1 Answer
- Newest
- Most votes
- Most comments
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.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 6 months ago