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

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

In this guide, we will create an AWS IAM user and an associated access key using Pulumi. This access key will allow programmatic access to AWS resources. We will also export the access key ID and secret access key as stack outputs for easy access.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

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

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

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

Key Points

  • We created an IAM user named exampleUser.
  • We generated an access key for the IAM user.
  • We exported the access key ID and secret access key as stack outputs.

Summary

We successfully deployed an AWS IAM user and an associated access key using Pulumi. The access key ID and secret access key were exported for use in programmatic access to AWS resources. This setup is essential for securely managing access to AWS services through automated scripts or applications.

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