# AccessKeyProps

Properties for defining an IAM access key.

Used as props by: [AccessKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.AccessKey.html)

- Source: [`aws-iam/lib/access-key.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-iam/lib/access-key.ts#L54)
- Type last changed: v2.7.0 · 12 Jan 2022

## Example

TypeScript:

```ts
// Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
const user = new iam.User(this, 'User');
const accessKey = new iam.AccessKey(this, 'AccessKey', { user });
const secret = new secretsmanager.Secret(this, 'Secret', {
	secretStringValue: accessKey.secretAccessKey,
});
```

Python:

```python
# Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
user = iam.User(self, "User")
access_key = iam.AccessKey(self, "AccessKey", user=user)
secret = secretsmanager.Secret(self, "Secret",
    secret_string_value=access_key.secret_access_key
)
```

Java:

```java
// Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
User user = new User(this, "User");
AccessKey accessKey = AccessKey.Builder.create(this, "AccessKey").user(user).build();
Secret secret = Secret.Builder.create(this, "Secret")
        .secretStringValue(accessKey.getSecretAccessKey())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
var user = new User(this, "User");
var accessKey = new AccessKey(this, "AccessKey", new AccessKeyProps { User = user });
var secret = new Secret(this, "Secret", new SecretProps {
    SecretStringValue = accessKey.SecretAccessKey
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
user := iam.NewUser(this, jsii.String("User"))
accessKey := iam.NewAccessKey(this, jsii.String("AccessKey"), &AccessKeyProps{
	User: User,
})
secret := secretsmanager.NewSecret(this, jsii.String("Secret"), &SecretProps{
	SecretStringValue: accessKey.SecretAccessKey,
})
```

## Properties

- `serial`: number — A CloudFormation-specific value that signifies the access key should be replaced/rotated.

  **Default:** No serial value

  This value can only be incremented. Incrementing this
  value will cause CloudFormation to replace the Access Key resource.

- `status`: [AccessKeyStatus](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.AccessKeyStatus.html) — The status of the access key.

  **Default:** The access key is active

  An Active access key is allowed to be used
  to make API calls; An Inactive key cannot.

- `user`: [IUser](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IUser.html) (required) — The IAM user this key will belong to.

  Changing this value will result in the access key being deleted and a new
  access key (with a different ID and secret value) being assigned to the new
  user.
