前提・実現したいこと
TerraformでIAMユーザーの作成
を実装しており、以下の実現をしたいです。
- IAMユーザーの作成
- 初期パスワードの作成
- 初回ログイン時、パスワード強制リセット有効
- 当該ユーザーによるパスワード変更の許可
公式ドキュメントを参考に、aws_iam_user_login_profile
を実装してますが、エラーが出力され、IAMユーザーのパスワード作成
に失敗します。
パスワード付きIAMユーザーの作成ができればと思っています。
解消方法を教えていただきたいです。
- リソースファイル
- .terraform - iam_user.tf - main.tf - variables.tf - version.tf - terraform.tfstate - cert(ディレクトリ) - iam_test.public.gpg
エラーメッセージ
Error: error encrypting password during IAM User Login Profile (iam_test.test_operator) creation: Error encrypting Password: error parsing given PGP key: openpgp: unsupported feature: unsupported oid: 2b060104019755010501 on iam_user.tf line 21, in resource "aws_iam_user_login_profile" "iam_test_login_profile": 21: resource "aws_iam_user_login_profile" "iam_test_login_profile" { Error: error encrypting password during IAM User Login Profile (iam_test.test_admin) creation: Error encrypting Password: error parsing given PGP key: openpgp: unsupported feature: unsupported oid: 2b060104019755010501 on iam_user.tf line 21, in resource "aws_iam_user_login_profile" "iam_test_login_profile": 21: resource "aws_iam_user_login_profile" "iam_test_login_profile" { Error: error encrypting password during IAM User Login Profile (iam_test.test_developer) creation: Error encrypting Password: error parsing given PGP key: openpgp: unsupported feature: unsupported oid: 2b060104019755010501 on iam_user.tf line 21, in resource "aws_iam_user_login_profile" "iam_test_login_profile": 21: resource "aws_iam_user_login_profile" "iam_test_login_profile" {
該当のソースコード
- iam_user.tf
resource "aws_iam_user" "iam_test" { count = length(var.aws_iam_user) name = element(var.aws_iam_user, count.index) path = "/" force_destroy = true } resource "aws_iam_user_group_membership" "iam_test_group_membership" { count = length(var.aws_iam_group) user = element(var.aws_iam_user, count.index) groups = [ element(var.aws_iam_group, count.index), ] depends_on = [ aws_iam_user.iam_test ] } resource "aws_iam_user_login_profile" "iam_test_login_profile" { count = length(var.aws_iam_user) user = element(var.aws_iam_user, count.index) pgp_key = filebase64("./cert/iam_test.public.gpg") password_reset_required = true password_length = "20" } output "aws_iam_user_password" { value = aws_iam_user_login_profile.iam_test_login_profile.*.encrypted_password }
- variables.tf
variable "aws_iam_user" { type = list(string) default = [ "iam_test.test_admin", "iam_test.test_developer", "iam_test.test_operator", ] } variable "aws_iam_group" { type = list(string) default = [ "iam_test_administrator", "iam_test_development", "iam_test_operators", ] }
- main.tf
provider "aws" { access_key = "xxx" secret_key = "xxx" region = "ap-northeast-1" default_tags { tags = { env = "iam_test" } } }
- version.tf
terraform { required_providers { aws = { source = "hashicorp/aws" version = ">= 3.24.0" } } required_version = ">= 0.14.0" }
- terraform.tfstate
{ "version": 4, "terraform_version": "0.14.6", "serial": 281, "lineage": "xxx", "outputs": {}, "resources": [] }
- cert/iam_test.public.gpg(
公開鍵バイナリファイル
)
試したこと
- terraform plan時に特にエラーなし
- terraform apply後、エラー出力される
補足情報(FW/ツールのバージョンなど)
$ tfenv version-name 0.14.6 $ terraform version Terraform v0.14.6 + provider registry.terraform.io/hashicorp/aws v3.63.0 Your version of Terraform is out of date! The latest version is 1.0.10. You can update by downloading from https://www.terraform.io/downloads.html
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。