3 Ways to Configure Terraform to use your AWS Account

<p>There are basically 3 different approaches you can use to allow Terraform to connect and authenticate successfully to AWS.</p> <p><strong>For your consideration:</strong></p> <p>It is advisable that you create a dedicated set of AWS credentials from the IAM console with programmatic access for your Terraform CLI. Make sure you grant least privileged based permissions, instead of full admin access, to limit the potential blast radius of Terraform.</p> <h1>Approach #1: Embed credentials directly into the Terraform template file</h1> <pre> terraform { required_providers { aws = { source = &quot;hashicorp/aws&quot; version = &quot;~&gt; 4.0.0&quot; } } } provider &quot;aws&quot; { region = &quot;us-east-1&quot; access_key = &quot;your_aws_access_key&quot; secret_key = &quot;your_aws_secret_access_key&quot; }</pre> <p>In the above&nbsp;<code>main.tf</code>&nbsp;file, you can simply add your AWS account&rsquo;s credentials in the&nbsp;<code>access_key</code>&nbsp;and&nbsp;<code>secret_key</code>&nbsp;properties which Terraform would use when connecting to your AWS account.</p> <p><a href="https://banhawy.medium.com/3-ways-to-configure-terraform-to-use-your-aws-account-fb00a08ded5"><strong>Learn More</strong></a></p>
Tags: AWS Account