How do we get terraform to work without giving it full access?

0

We currently use EC2 full access, S3 full access, & elastic load balancing full access to get terraform up and running. These permissions are turned on and off after every terraform build. This is a security concern. I am wondering what permissions will allow terraform to work without giving full access?

3 個答案
1

Afraid Terraform will need the access to create, delete and modify the resources. The polices applied to the TF user/role will need to be appropriate for provisioning.

profile picture
專家
已回答 2 個月前
profile picture
專家
已審閱 2 個月前
0

Roles uses by IaC are usually very powerful with administrative rights to many resources. The best practice is to use a CI/CD pipeline and only enable those pipelines to use the role, protecting them using secrets inside the CI/CD tool. That way you keep those credentials away from humans (thus leaks) and only proper procedures through CI/CD leverage the role properly to deploy resources.

Hope this helps!

AWS
已回答 2 個月前
0

There is an RFE open for this (doesn't look like it has progressed much) https://github.com/hashicorp/terraform-provider-aws/issues/32823

It makes reference to a stackoverflow question that asks what you're asking https://stackoverflow.com/questions/51273227/whats-the-most-efficient-way-to-determine-the-minimum-aws-permissions-necessary

And it appears you can achieve what you need by running TF_LOG=trace terraform apply --auto-approve &> log.log and then cat log.log | grep "DEBUG: Request".

A more recent reply suggests the log format has changed and you now need to grep for aws.operation=

profile picture
專家
Steve_M
已回答 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南