1
votes

Is there another way to get ARN of created Subnet Resource AWS::EC2::Subnet via Fn::GetAtt intrinsic function. Subnet resource only returns AvailabilityZone, Ipv6CidrBlocks, NetworkAclAssociationId, VpcId.

Documentation: https://docs.aws.amazon.com/en_pv/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#aws-resource-ec2-subnet-return-values

1

1 Answers

3
votes

Since the ARN of Subnet is in this format arn:aws:ec2:REGION:ACCONT_ID:subnet/SUBNET_ID. By using intrinsic function Fn::Join you can generate ARN of subnet.

Example: arn:aws:ec2:ap-southeast-1:767022272945:subnet/subnet-0d42d2235s3a2531d

  !Join
    - ''
    - - 'arn:aws:ec2:'
      - !Ref 'AWS::Region'
      - ':'
      - !Ref 'AWS::AccountId'
      - ':subnet/'
      - Fn::ImportValue:
          Fn::Sub: VPC-SubnetId