amazon-web-servicesaws-cloudformation

Give my IP as the default value in an AWS CFN parameter


When creating a Security Group manually via the console, the Source for a rule can be selected as "My IP" which automatically fetches the client browser's IP address as a /32 CIDR.

Is there a way to have a CloudFormation parameter grab the clients IP address as the default when running the CF template from the console?

Use case: I have a bastion host / access host that I build when needed from a CFN template. Each time I build the host I have to visit a 'WhatsMyIP' type site to get my current IP address and copy and paste it into my CFN parameter. As the AWS Console has a way of grabbing the IP automatically and formatting it as a /32 CIDR it would be good if this was available as a function in a CFN template as well.


Solution

  • There is no way to do that, this feature on the AWS console is a pure AWS console UI implementation and is not part of the AWS API nor of the default CloudFormation parameters. However, you could have a look at the AWS CDK which lets you define your resources in a language of your choosing and can also immediately initiate the deployment if you so want.

    This would allow you to use the language you're defining your resources in, to make the call to whatsmyip and automate the process.