Creates AWS Resources
Before you configure the HCP Vault AWS auth method, you must create the necessary resources in AWS. The AWS auth method will require an IAM policy that permits the appropriate access for the auth method, an IAM user with programmatic access, and one or more roles that you will assign to other AWS services that require authentication to Vault.
Create the IAM Policy for your IAM User
The below policy needs to be attached to the IAM User you are creating in AWS.
IAM User Cloud Formation Template
Note: You may need to add more IAM permissions if you receive errors authenticating
Create IAM Policy for your IAM Role
IAM Role Cloud Formation Template
You will now create the IAM policy for your IAM Role. You will need to attach this to your IAM Role to allow Vault to connect to it and authenticate. You can replace vaultauth with the name of the IAM Role and IAM User that you have created.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"iam:GetInstanceProfile",
"iam:GetUser",
"iam:GetRole"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": [
"arn:aws:iam::<aws-account-number>:role/vaultauth"
]
},
{
"Sid": "ManageOwnAccessKeys",
"Effect": "Allow",
"Action": [
"iam:CreateAccessKey",
"iam:DeleteAccessKey",
"iam:GetAccessKeyLastUsed",
"iam:GetUser",
"iam:ListAccessKeys",
"iam:UpdateAccessKey"
],
"Resource": "arn:aws:iam::*:user/vaultauth"
}
]
}
Create the connections to Vault via AWS IAM User and AWS IAM Role
Enable aws auth on your vault instance.
Check to see if the vault auth aws method has been enabled.
Next connect the IAM role you created in AWS to the Vault aws auth backend. This will configure the AWS auth method with access to your AWS account using the Access key ID and Secret Access Key previously created for the IAM User you created in AWS.
Create Vault role for connection to AWS IAM Role
Configure the AWS auth method to trust the AWS IAM role previously
created and attach the vault-policy-for-aws-ec2role to the token
provided by the AWS auth method. Replace
Note: The IAM User Arn will look like the following: arn:aws:iam::<aws-account-number>:user/vaultauth
vault write auth/aws/role/vaultauth \
auth_type=iam \
bound_iam_principal_arn=arn:aws:iam::<aws-account-number>:role/vaultauth \
policies=default,allinone
List the roles you created for the aws auth method.
Setup authentication to Vault via an IAM Role
- auth/aws/role/
- this is the name of the role you are creating in vault - auth_type=iam - this notes that vault will authenticate via an IAM role
- bound_iam_principal_arn - this is the IAM Role arn that you will get from your AWS account
- policies - these are the policy(s) you will associate with your vault role