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
resource "aws_iam_account_alias" "alias" {
account_alias = var.account_alias
}
resource "aws_iam_account_password_policy" "strict" {
minimum_password_length = 12
resource "aws_iam_account_alias" "alias" {
account_alias = "blooper"
}
resource "aws_iam_user" "terraform" {
name = "terraform"
resource "aws_iam_account_alias" "account_alias" {
account_alias = "alfie-salomon-organization-name"
}
resource "aws_iam_account_password_policy" "strict" {
minimum_password_length = 8
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
Parameters
-
account_alias
required - string -
id
optional computed - string
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.
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.
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.