AccessKey
The AccessKey resource allows you to manage AWS IAM AccessKeys for IAM users, enabling programmatic access to AWS services.
Minimal Example
Section titled “Minimal Example”Create a basic IAM AccessKey for a specified user with required properties:
import AWS from "alchemy/aws/control";
const basicAccessKey = await AWS.IAM.AccessKey("basicAccessKey", { UserName: "john.doe", Status: "Active" // Optional: Can be "Active" or "Inactive"});
Advanced Configuration
Section titled “Advanced Configuration”Create an AccessKey with additional configuration, such as specifying a serial number:
const advancedAccessKey = await AWS.IAM.AccessKey("advancedAccessKey", { UserName: "jane.smith", Serial: 123456789, // Optional: Serial number associated with the key Status: "Active"});
Adopting Existing AccessKey
Section titled “Adopting Existing AccessKey”If you want to adopt an existing AccessKey without failing, use the adopt
property:
const adoptedAccessKey = await AWS.IAM.AccessKey("adoptedAccessKey", { UserName: "existing.user", adopt: true // If true, adopts existing resource instead of failing});
AccessKey Rotation
Section titled “AccessKey Rotation”You can create a new AccessKey to replace an existing one for a user:
const newAccessKey = await AWS.IAM.AccessKey("newAccessKey", { UserName: "developer.user", Status: "Active"});
// Assume there is a function to delete the old keyawait AWS.IAM.AccessKey("oldAccessKey", { UserName: "developer.user", Status: "Inactive" // Mark old key as inactive});