# CfnAPIKeyProps

Properties for defining a `CfnAPIKey`.

Used as props by: [CfnAPIKey](/cdk/api/v2/docs/aws-cdk-lib.aws_location.CfnAPIKey.html)

- Source: Generated at build time
- Type last changed: v2.119.0 · 11 Jan 2024

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_location as location } from 'aws-cdk-lib';
const cfnAPIKeyProps: location.CfnAPIKeyProps = {
  keyName: 'keyName',
  restrictions: {
    allowActions: ['allowActions'],
    allowResources: ['allowResources'],

    // the properties below are optional
    allowAndroidApps: [{
      certificateFingerprint: 'certificateFingerprint',
      package: 'package',
    }],
    allowAppleApps: [{
      bundleId: 'bundleId',
    }],
    allowReferers: ['allowReferers'],
  },

  // the properties below are optional
  description: 'description',
  expireTime: 'expireTime',
  forceDelete: false,
  forceUpdate: false,
  noExpiry: false,
  tags: [{
    key: 'key',
    value: 'value',
  }],
};
```

Python:

```python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_location as location

cfn_api_key_props = location.CfnAPIKeyProps(
    key_name="keyName",
    restrictions=location.CfnAPIKey.ApiKeyRestrictionsProperty(
        allow_actions=["allowActions"],
        allow_resources=["allowResources"],

        # the properties below are optional
        allow_android_apps=[location.CfnAPIKey.AndroidAppProperty(
            certificate_fingerprint="certificateFingerprint",
            package="package"
        )],
        allow_apple_apps=[location.CfnAPIKey.AppleAppProperty(
            bundle_id="bundleId"
        )],
        allow_referers=["allowReferers"]
    ),

    # the properties below are optional
    description="description",
    expire_time="expireTime",
    force_delete=False,
    force_update=False,
    no_expiry=False,
    tags=[CfnTag(
        key="key",
        value="value"
    )]
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.location.*;

CfnAPIKeyProps cfnAPIKeyProps = CfnAPIKeyProps.builder()
        .keyName("keyName")
        .restrictions(ApiKeyRestrictionsProperty.builder()
                .allowActions(List.of("allowActions"))
                .allowResources(List.of("allowResources"))

                // the properties below are optional
                .allowAndroidApps(List.of(AndroidAppProperty.builder()
                        .certificateFingerprint("certificateFingerprint")
                        .package("package")
                        .build()))
                .allowAppleApps(List.of(AppleAppProperty.builder()
                        .bundleId("bundleId")
                        .build()))
                .allowReferers(List.of("allowReferers"))
                .build())

        // the properties below are optional
        .description("description")
        .expireTime("expireTime")
        .forceDelete(false)
        .forceUpdate(false)
        .noExpiry(false)
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Location;

var cfnAPIKeyProps = new CfnAPIKeyProps {
    KeyName = "keyName",
    Restrictions = new ApiKeyRestrictionsProperty {
        AllowActions = new [] { "allowActions" },
        AllowResources = new [] { "allowResources" },

        // the properties below are optional
        AllowAndroidApps = new [] { new AndroidAppProperty {
            CertificateFingerprint = "certificateFingerprint",
            Package = "package"
        } },
        AllowAppleApps = new [] { new AppleAppProperty {
            BundleId = "bundleId"
        } },
        AllowReferers = new [] { "allowReferers" }
    },

    // the properties below are optional
    Description = "description",
    ExpireTime = "expireTime",
    ForceDelete = false,
    ForceUpdate = false,
    NoExpiry = false,
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnAPIKeyProps := &CfnAPIKeyProps{
	KeyName: jsii.String("keyName"),
	Restrictions: &ApiKeyRestrictionsProperty{
		AllowActions: []*string{
			jsii.String("allowActions"),
		},
		AllowResources: []*string{
			jsii.String("allowResources"),
		},

		// the properties below are optional
		AllowAndroidApps: []interface{}{
			&AndroidAppProperty{
				CertificateFingerprint: jsii.String("certificateFingerprint"),
				Package: jsii.String("package"),
			},
		},
		AllowAppleApps: []interface{}{
			&AppleAppProperty{
				BundleId: jsii.String("bundleId"),
			},
		},
		AllowReferers: []*string{
			jsii.String("allowReferers"),
		},
	},

	// the properties below are optional
	Description: jsii.String("description"),
	ExpireTime: jsii.String("expireTime"),
	ForceDelete: jsii.Boolean(false),
	ForceUpdate: jsii.Boolean(false),
	NoExpiry: jsii.Boolean(false),
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
}
```

## Properties

- `description`: string — Updates the description for the API key resource.

- `expireTime`: string — The optional timestamp for when the API key resource will expire in [ISO 8601 format](https://docs.aws.amazon.com/https://www.iso.org/iso-8601-date-and-time-format.html) .

- `forceDelete`: boolean | [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — ForceDelete bypasses an API key's expiry conditions and deletes the key.

  Set the parameter `true` to delete the key or to `false` to not preemptively delete the API key.

  Valid values: `true` , or `false` .

  > This action is irreversible. Only use ForceDelete if you are certain the key is no longer in use.

- `forceUpdate`: boolean | [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — The boolean flag to be included for updating `ExpireTime` or Restrictions details.

  Must be set to `true` to update an API key resource that has been used in the past 7 days. `False` if force update is not preferred.

- `keyName`: string (required) — A custom name for the API key resource.

  Requirements:

  - Contain only alphanumeric characters (A–Z, a–z, 0–9), hyphens (-), periods (.), and underscores (_).
  - Must be a unique API key name.
  - No spaces allowed. For example, `ExampleAPIKey` .

- `noExpiry`: boolean | [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) — Whether the API key should expire.

  Set to `true` to set the API key to have no expiration time.

- `restrictions`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnAPIKey.ApiKeyRestrictionsProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_location.CfnAPIKey.ApiKeyRestrictionsProperty.html) (required) — The API key restrictions for the API key resource.

- `tags`: [CfnTag](/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — Applies one or more tags to the map resource.

  A tag is a key-value pair that helps manage, identify, search, and filter your resources by labelling them.
