Skip to content

aws-samples/ec2-former2

Folders and files

NameName
Last commit message
Last commit date
Aug 25, 2024
Apr 18, 2025
Apr 18, 2025
Mar 16, 2023
Mar 16, 2023
Mar 16, 2023
Apr 18, 2025
Mar 16, 2023

ec2-former2

Former2 allows you to generate IaC (Infrastructure as Code) (such as CloudFormation, CDK, Terraform, etc) from existing AWS resources and is mentioned on AWS Open Source Blog (Accelerate infrastructure as code development with open source Former2 and How DNAnexus used the open source Former2 project to create infrastructure as code templates for their disaster recovery pipeline).

Some users have challenges creating access keys while others express security concerns about entering AWS security credentials on a public website, and would prefer a private web instance. However, Former2 requires browser helper extension that only works with websites that has domain names 127.0.0.1, localhost, former2.com and www.former2.com.

This CloudFormation template creates an EC2 instance hosting Former2 in your AWS account. You can connect to the instance with Amazon DCV remote display protocol to generate and download IaC templates using temporary security credentials.

About CloudFormation templates

EC2 instances must be provisioned in a subnet with IPv4 internet connectivity.

Getting started

Provision EC2 with CloudFormation

Download the CloudFormation template(AL2023 or AL2). Login to your CloudFormation console. Choose Create Stack, Upload a template file, Choose File, select your .yaml file and choose Next. Enter a Stack name and specify parameters values.

EC2

  • ec2Name: EC2 instance name
  • processorArchitecture: Intel/AMD x86_64 or Graviton arm64. Default is Graviton (arm64)
  • instanceType: EC2 instance types. Do ensure type matches processor architecture.

Network

  • vpcID: VPC with internet connectivity. Select default VPC if unsure
  • subnetID: subnet with internet connectivity. Select subnet in default VPC if unsure
  • displayPublicIP: set this to No if your EC2 instance will not receive public IP address. EC2 private IP will be displayed in CloudFormation Outputs section instead. Default is Yes
  • assignStaticIP: associates a static public IPv4 address using Elastic IP address. Default is Yes

Remote Access

  • ingressIPv4: allowed IPv4 source prefix to your EC2 instance, e.g. 1.2.3.4/32. You can get your source IP from https://checkip.amazonaws.com
  • ingressIPv6: allowed IPv6 source prefix to your EC2 instance. Use ::1/128 to block all incoming IPv6 access. Default is ::/0

EBS

Continue Next with Configure stack options, Review Stack, and click Submit to launch your stack. After your stack has been successfully created, its status changes to CREATE_COMPLETE.

Using

Once provisioned, go to CloudFormation stack Outputs section and use the Values associated with the following Keys

Set login password

  • SSMSessionManager: open URL in a new browser tab for shell access.

    From session manager terminal, set your ec2-user password with the command sudo passwd ec2-user

Connect

  • DCVwebConsole: open URL in a new browser tab, and connect to your EC2 instance

    Login as ec2-user and your configured password

    Launch Firefox and navigate to Former2 site at http://localhost. Install Former 2 Helper for Mozilla Firefox

ec2.png

Credentials

  • In your DCV session, launch Terminal and run the command /home/ec2-user/get-iam-creds.

    Use these values to enter IAM credentials (Access Key ID, Secret Access Key, Session Token) at http://localhost/#section-setup-credentials

ec2.png

Using Former2

Refer to Accelerate infrastructure as code development with open source Former2 blog post for usage guidance.

Attribution

CloudFormation template downloads Former2 web codes from Ian Mckay's GitHub repo which are released under MIT license.

Updating web codes

Former2 is under active development. To download latest codes, login to EC2 instance and run /home/ec2-user/update-former2 script.

About DCV web console

DCV supports file transfer. Native clients can be downloaded from Amazon DCV site

file transfer

Usage indicates acceptance of DCV EULA.

Clean Up

To remove created resources, delete your created CloudFormation stack

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

EC2 instance running Former2 for generating IaC scripts from existing AWS resources with temporary security credentials

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks