1. Answers
  2. Creating an AWS IAM Access Key

How do I build an AWS IAM access key?

In this guide, we will create an AWS IAM user and generate an access key for that user using Pulumi. This access key can be used for programmatic access to AWS services.

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 IAM user
const accessKey = new aws.iam.AccessKey("myAccessKey", {
    user: user.name,
});

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

Key Points

  • IAM User: We created an IAM user named myUser.
  • Access Key: We generated an access key for the IAM user.
  • Exports: The access key ID and secret access key are exported for use.

Summary

In this guide, we created an AWS IAM user and generated an access key for the user using Pulumi. These credentials can be used to programmatically access AWS services. The access key ID and secret access key are exported as stack outputs, making them accessible for further use.

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