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 upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.