AWS IAM Account Alias

This page shows how to write Terraform for IAM Account Alias and write them securely.

aws_iam_account_alias (Terraform)

The Account Alias in IAM can be configured in Terraform with the resource name aws_iam_account_alias. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub

iam-common.tf#L5
resource "aws_iam_account_alias" "alias" {
  account_alias                  = var.account_alias
}

resource "aws_iam_account_password_policy" "strict" {
  minimum_password_length        = 12
account.tf#L1
resource "aws_iam_account_alias" "alias" {
  account_alias = "blooper"
}

resource "aws_iam_user" "terraform" {
  name = "terraform"
main.tf#L6
resource "aws_iam_account_alias" "account_alias" {
  account_alias = "alfie-salomon-organization-name"
}

resource "aws_iam_account_password_policy" "strict" {
  minimum_password_length        = 8
main.tf#L5
resource "aws_iam_account_alias" "this" {
  account_alias = var.account_alias
}

resource "aws_iam_account_password_policy" "this" {
  count = var.create_account_password_policy ? 1 : 0

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

-> Note: There is only a single account alias per AWS account. Manages the account alias for the AWS Account.

Tips: Best Practices for The Other AWS IAM Resources

In addition to the aws_iam_account_password_policy, AWS IAM has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

aws_iam_account_password_policy

Ensure AWS IAM account password policies requires long passwords

It's better to enforce the use of long and complex passwords to reduce the risk of bruteforce attacks.

Review your AWS IAM settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

CloudFormation Example

CloudFormation code does not have the related resource.

Frequently asked questions

What is AWS IAM Account Alias?

AWS IAM Account Alias is a resource for IAM of Amazon Web Service. Settings can be wrote in Terraform.

Where can I find the example code for the AWS IAM Account Alias?

For Terraform, the ctschuster/aws-infra, blooper05/toward-the-terra and alfiesal/terraform-examples source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.