Skip to content

[Bug]:aws_iam_account_alias data source fails when an AWS Account has no IAM alias #29324

@gswallow

Description

@gswallow

Terraform Core Version

1.1.5

AWS Provider Version

3.22.0

Affected Resource(s)

The aws_iam_account_alias data source, when operating in a brand new AWS account where the administrator has not set an IAM alias yet, returns an error: "no IAM account alias found."

Yet there is a default alias which matches the 12-digit account number of the AWS account.

Expected Behavior

Perhaps a reasonable alternative is to return the 12-digit account ID when an account alias does not exist?

Actual Behavior

Terraform plan fails.

Relevant Error/Panic Output Snippet

Error: no IAM account alias found

   with module.bucket.data.aws_iam_account_alias.current,
   on .terraform/modules/bucket/terraform-backend-bucket/data.tf line 1, in data "aws_iam_account_alias" "current":
    1: data "aws_iam_account_alias" "current" {

Terraform Configuration Files

data "aws_iam_account_alias" "current" {}

Steps to Reproduce

run terraform plan in a new AWS account

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequests to existing resources that expand the functionality or scope.service/iamIssues and PRs that pertain to the iam service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions