Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::AppSync::ApiKey

The AWS::AppSync::ApiKey resource creates a unique key that you can distribute to clients who are executing GraphQL operations with AWS AppSync that require an API key.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::AppSync::ApiKey", "Properties" : { "Description" : String, "Expires" : Number, "ApiId" : String } }

YAML

Type: "AWS::AppSync::ApiKey" Properties: Description: String Expires: Number ApiId: String

Properties

Description

Unique description of your API Key.

Required: No

Type: String

Update requires: No interruption

Expires

Expiration time of the API Key in seconds (using Unix Epoch time), with a minimum of 1 day and a maximum of 365 days.

Required: Yes

Type: Number

Update requires: No interruption

ApiId

Unique AWS AppSync GraphQL API Identifier for this API Key.

Required: No

Type: String

Update requires: Replacement

Return Values

Ref

When you pass the logical ID of an AWS::AppSync::ApiKey resource to the intrinsic Ref function, the function returns the ARN of the API Key, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/apikey/apikeya1bzhi.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

ApiKey

The API key.

Arn

The Amazon Resource Name (ARN) of the API key, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/apikey/apikeya1bzhi.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Examples

API Key creation example

The following example creates an API Key and associates it with an existing GraphQL API by passing the GraphQL API Id as a paramater.

JSON

{ "Parameters": { "graphQlApiId": { "Type": "String" }, "apiKeyDescription": { "Type": "String" }, "apiKeyExpires": { "Type": "Number" } }, "Resources": { "ApiKey": { "Type": "AWS::AppSync::ApiKey", "Properties": { "ApiId": { "Ref": "graphQlApiId" }, "Description": { "Ref": "apiKeyDescription" }, "Expires": { "Ref": "apiKeyExpires" } } } } }

YAML

Parameters: graphQlApiId: Type: String apiKeyDescription: Type: String apiKeyExpires: Type: Number Resources: ApiKey: Type: AWS::AppSync::ApiKey Properties: ApiId: Ref: graphQlApiId Description: Ref: apiKeyDescription Expires: Ref: apiKeyExpires

See Also