AWS Fundamentals Logo
AWS Fundamentals
L1 ConstructAWS::IAM::AccessKey

CfnAccessKey

Creates a new AWS secret access key and corresponding AWS access key ID for the specified user. The default status for new keys is `Active` . For information about quotas on the number of keys you can create, see [IAM and AWS STS quotas](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html) in the *IAM User Guide* . > To ensure the security of your AWS account , the secret access key is accessible only during key and user creation. You must save the key (for example, in a text file) if you want to be able to access it again. If a secret key is lost, you can rotate access keys by increasing the value of the `serial` property.

Import

import { CfnAccessKey } from 'aws-cdk-lib/aws-iam';

Or use the module namespace:

import * as iam from 'aws-cdk-lib/aws-iam';
// iam.CfnAccessKey

Properties

Configuration passed to the constructor as CfnAccessKeyProps.

userNameRequired
string

The name of the IAM user that the new key will belong to. This parameter allows (through its [regex pattern](https://docs.aws.amazon.com/http://wikipedia.org/wiki/regex) ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

serialOptional
number

This value is specific to CloudFormation and can only be *incremented* . Incrementing this value notifies CloudFormation that you want to rotate your access key. When you update your stack, CloudFormation will replace the existing access key with a new key.

statusOptional
string

The status of the access key. `Active` means that the key is valid for API calls, while `Inactive` means it is not.

CloudFormation Resource

This L1 construct maps directly to the following CloudFormation resource type.

Get the AWS IAM Cheat Sheet

Everything you need to know about AWS IAM on one page. HD quality, print-friendly.

Download Free Infographic