1. Answers
  2. Provisioning an AWS IAM Access Key with Pulumi

How do I provision an AWS IAM access key with Pulumi?

In this guide, we will provision an AWS IAM user and generate an access key for that user using Pulumi. This will allow programmatic access to AWS services using the generated credentials.

Key Points:

  • We will create an IAM user.
  • We will generate an access key for the IAM user.
  • The access key will be stored securely using Pulumi’s secret management.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create an IAM user
const user = new aws.iam.User("myUser", {
    name: "myUser",
});

// Create an access key for the user
const accessKey = new aws.iam.AccessKey("myUserAccessKey", {
    user: user.name,
});

// Export the access key ID and secret access key
export const accessKeyId = accessKey.id;
export const secretAccessKey = pulumi.secret(accessKey.secret);

Summary

In this example, we created an IAM user and generated an access key for that user using Pulumi. The access key ID and secret access key were exported, with the secret access key being stored securely using Pulumi’s secret management. This setup allows programmatic access to AWS services using the generated credentials.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up