Aws_iam_user_login_profile and PGP Key workflow

Hi all :wink:

I try to use GPG Key (instead of keybase) to generate user password.
This is my process :

In Terraform :

resource "aws_iam_user_login_profile" "newuser" {                                                                    
    user    = aws_iam_user.newuser.name                                                                
    pgp_key = base64encode(file(var.key_path))                                                        
}  

And then :

gpg --gen-key --batch key_conf
gpg -o mykey --armor --export 

terraform apply -var "key_path=mykey"

But I always get this error :

Error: error encrypting password during IAM User Login Profile (user-auto-test) creation: Error encrypting Password: error parsing given PGP key: openpgp: invalid data: tag byte does not have MSB set

Any clue please ?
Thanks a lot.

Oh my bad, the problem is the export method.
With

gpg --export <key_name>| base64 > public_key_file

It works perfectly :wink:

Hey! I was doing the same thing here. Can you share with key_conf or the way you created the gpg key in more detail, thank you!

Hi, I came across this thread and the reply from @opsrom helped me solve the issue.

For the gpg key, I just generated it with the command gpg --gen-key