My First AWS Security as Code
Generate the resources import
terraform query -generate-config-out=generated.tf
or
./generate.sh
LICENSE
MIT


About: AWS Community Builder | Software Engineer | Focus on topics: Microservices, Cloud Computing, and Cyber Security.
Cover image is generated by AI
A long time ago... I want to manage my IAM Role with Terraform. But, I'm quite lazy for writing it manually... Especially for my existing IAM Role. I heard about Terraform Search, which helps me import existing resources to write the resource configuration! Wow!
Imagine you write the query something like this.
list aws_iam_role dev {
provider = aws
}
Run this command.
terraform query -generate-config-out=generated.tf
Boom! You got a generated resource file with the import blocks.
Easy, right?
If you want to read more, please visit here.
Keep in mind. Terraform Search supports are based on the Terraform provider.
Okay, you need to do it locally because HCP won't have the beta right now, except that Terraform 1.14 has been released. So, basically, these are my steps. In this case, I want to manage the state in HCP Terraform.
main.tf to configure the provider, in this case AWS provider..tfquery.hcl file (look above section).terraform init.terraform query -generate-config-out=generated.tf.terraform plan just to ensure it will import!terraform apply if I'm sure of the configuration.Notes:
You can visit my repo here.
terraform query -generate-config-out=generated.tf
or
./generate.sh
MIT
Thank you for reading!
If you have any feedback, feel free to comment here.