🏳️AWS2Terraform

Gitpod Codacy Badge gradle build Create Release Status Not yet Language Java License

This project is intended to extract resources created in AWS as Terraform resources.

I implemented the CLI using Spring Shell project and JCommander library.

The goal of the current project is an extract program for Terraform resources, and will be developed in the future towards generating tfvar and tfstates according to standardized Terraform code.

AWS Services supported

Supported AWS Services

  1. EC2

    • EC2 Instances

    • Launch Templates

  2. VPCs

    • egress-only-internet-gateways

    • internet-gateways

    • nat-gateways

    • route-tables

    • security-groups

    • subnets

    • vpcs

  3. Api Gateway

    • api-gateway-resources

    • api-gateway-rest-apis

  4. Cloud Watch Logs

    • cloud-watch-log-groups

    • resource-policies

  5. ECR

    • ecr-repository

  6. EFS

    • fs-file-systems

  7. EKS

    • eks-clusters

  8. ElastiCache

    • elasti-cache-clusters

    • elasti-cache-replication-groups

    • elasti-cache-subnet-groups

  9. Elastic Search(OpenSearch)

    • elastic-search-domains

  10. ELB

    • load-balancer-listeners

    • load-balancer-target-groups

    • load-balancers

  11. IAM

    • iam-instance-profiles

    • iam-policies

    • iam-role-policies

    • iam-role-policy-attachment

    • iam-roles

  12. KMS

    • kms-keys

  13. MSK

    • msk-clusters

  14. RDS

    • rds-cluster-parameter-groups

    • rds-clusters

    • rds-option-groups

    • rds-subnet-groups

  15. S3

    • s3buckets

  16. It will be added gradually.

Run

java -jar terraform-generator-shell-[version].jar

Getting started

  1. configure region and profile.

export:>config --region ap-northeast-2 --profile default
Region is set to ap-northeast-2
Profile is set to default
  1. Use all-available-resources command to export all available-resources from aws.

  1. Exit shell and check out result files which is created on outout folder. *.tf files are terraform files, and *.cmd files are terraform import files.

Usage of Commands

How to check Spring Shell CLI Builtin option.

https://docs.spring.io/spring-shell/docs/2.0.1.BUILD-SNAPSHOT/reference/htmlsingle/#built-in-commands

Config Commands

You can configure AWS2Terraform profile and region via config commands. After that, you do not need to put common parameters when you run each command. Auto completion is available for parameter of region and profile.

Common Options

How to check command-specific options.

Last updated