Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pgp key in terraform for aws_iam_user_login_profile

I am new to terraform creating iam user using terraform

below is the .tf file

resource "aws_iam_user" "lb" {
  name = "Ec2_view"

  # path = "/system/"
  # tags = {
  #   tag-key = "tag-value"
  # }
}

resource "aws_iam_access_key" "lb" {
  user = "${aws_iam_user.lb.name}"
}

resource "aws_iam_user_policy" "lb_ro" {
  name = "test"
  user = "${aws_iam_user.lb.name}"

  policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "ec2:Describe*"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
EOF
}

resource "aws_iam_user_login_profile" "u" {
  user                    = "${aws_iam_user.lb.name}"
  password_reset_required = true
  pgp_key="keybase:terraform_user"
}

output "password" {
value="${aws_iam_user_login_profile.u.encrypted_password"
}

what does pgp_key mean in aws_iam_user_login_profile and steps to create pgp_key and using it in terraform code?

like image 552
Sugatur Deekshith S N Avatar asked Nov 28 '18 06:11

Sugatur Deekshith S N


People also ask

How do I get the access key and secret key in terraform?

So first I install the AWS CLI. Then we run aws configure. [ ] $ aws configure AWS Access Key ID []: ENTER-YOUR-ACCESS-KEY-HERE AWS Secret Access Key []: ENTER-YOUR-SECRET-KEY-HERE Default region name []: us-west-2 Default output format []

What is terraform key?

keys takes a map and returns a list containing the keys from that map. The keys are returned in lexicographical order, ensuring that the result will be identical as long as the keys in the map don't change.

What is Cidr_block in terraform?

cidr_block - (Optional) The IPv4 CIDR block for the VPC. CIDR can be explicitly set or it can be derived from IPAM using ipv4_netmask_length . instance_tenancy - (Optional) A tenancy option for instances launched into the VPC.


1 Answers

Got the answer

  1. Need to install Keybase in our local
  2. need to create Keybase key by using keybase pgp gen
  3. then give the reference of this Keybase key in your terraform code keybase:username_of_keybase
  4. Then terraform apply
  5. Then we need to get the decrypted password
terraform output -raw password | base64 --decode | keybase pgp decrypt
like image 104
Sugatur Deekshith S N Avatar answered Nov 15 '22 08:11

Sugatur Deekshith S N