1

I have AWS cloudformation stacks with ec2 instances that are entirely isolated from external traffic. They seldom need to be directly accessed. For cases when they do need to be accessed, I have a stack to launch a bastion host. Is there an easy way, that I've missed from the docs, of getting the IPv6 of the bastion host in the stack outputs ?

# Cloudformation snippet
Resources:
  BastionHost:
    Type: AWS::EC2::Instance
    Properties:
      KeyName: !Ref KeyName
      SubnetId: !Ref MyBastionSubnetId
      Ipv6AddressCount: 1
      ImageId: !Ref LatestAmiId
Outputs:
  BastionIP:
    # Problematically only returns an IPv4
    Value: !GetAtt BastionHost.PublicIp
    Description: Publicly addressable IP of bastion host
2

Neither AWS::EC2::Instance nor AWS::EC2::NetworkInterface seem to support it. You can make a feature request at CloudFormation Public Roadmap but it's going to be a while before they implement it.

Your best option is to create a CloudFormation Custom Resource which is essentially a Lambda function that will be given the instance ID as a parameter and than calls EC2.Client.describe_instances() and return the IPv6 address from there. It should be just a few lines of code.

Hope that helps :)

1
  • A custom resource is a viable alternative. We already use those for returning the cloudfront distribution endpoints from cognito.
    – GcL
    Oct 6 '20 at 23:34
0

There is a new feature request for accessing the IPv6 address via Cloudformation'S GetAtt, see https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/916 Maybe you can support this feature request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.