Hi,
As the title says, I am trying to get multiple AWS accounts authenticated when they log in with their ec2 instance. Unfortunately, I can only get my account-ID to auth into HashiCorp Vault. I am not sure if this is one of the limitations of the HCP since its hosted on the website. The process I have so far (after enabling aws):
vault write auth/aws/config/client \
access_key="AKIAxxxxx" \
secret_key="xxxx"
vault write auth/aws/role/${example_role_name} \
auth_type=iam \
bound_iam_principal_arn=${AWS_IAM_ROLE_ARN} \
policies={account-policy} \ #note, {account-policy} = a diff policy for each new user
max_ttl=1h
vault kv put secret/certs/${AWS_ACCOUNT_ID}/${AWS_IAM_ROLE}/cert1 cert="data" key="key"
So for the AWS policy for the access/secret user role that allowed aws to use my account as a valid account:
{
"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::956xxxxxx:role/<VaultRole>"
]
}
]
}
HCL Policies attached to the user, these are hard-coded paths:
# Write and manage secrets in key-value secrets engine
path "secret/data/certs/${AWS_ACCOUNT_ID}/${AWS_ACCOUNT_IAM_ROLE}/*" {
capabilities = ["read", "list" ]
}
path "secret/metadata/certs/${AWS_ACCOUNT_ID}/${AWS_ACCOUNT_IAM_ROLE}/*" {
capabilities = [ "list", "read" ]
}
# To enable secrets engines
path "sys/mounts/*" {
capabilities = [ "create", "read", "update", "delete" ]
}
On the client EC2 instance, I used this policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeInstances",
"iam:GetInstanceProfile",
"iam:GetUser",
"iam:GetRole",
"sts:GetCallerIdentity"
],
"Resource": "*"
}
]
}
So all of that only allowed my account to be auth when logged into HashiCorp Vault, but I need to be able to log into any account (i.e. any AWS account and role). Let me know if you need more information, but thanks for the help!