AWS AppSync API Key
This page shows how to write Terraform and CloudFormation for AWS AppSync API Key and write them securely.
aws_appsync_api_key (Terraform)
The API Key in AWS AppSync can be configured in Terraform with the resource name aws_appsync_api_key
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_appsync_api_key" "api_key" {
count = length(var.api_key)
api_id = element(var.api_id, lookup(var.api_key[count.index], "api_id"))
description = lookup(var.api_key[count.index], "description")
expires = lookup(var.api_key[count.index], "expires")
resource "aws_appsync_api_key" "appsync_api_key" {
count = var.enable_appsync_api_key ? 1 : 0
api_id = var.appsync_api_key_api_id != "" && !var.enable_appsync_graphql_api ? lower(var.appsync_api_key_api_id) : element(concat(aws_appsync_graphql_api.appsync_graphql_api.*.id, [""]), 0)
description = var.appsync_api_key_description
resource "aws_appsync_api_key" "appsync_api_key" {
count = var.enable_appsync_api_key ? 1 : 0
api_id = var.appsync_api_key_api_id != "" && !var.enable_appsync_graphql_api ? lower(var.appsync_api_key_api_id) : element(concat(aws_appsync_graphql_api.appsync_graphql_api.*.id, [""]), 0)
description = var.appsync_api_key_description
resource "aws_appsync_api_key" "main_key" {
api_id = aws_appsync_graphql_api.main.id
}
resource "aws_iam_role_policy_attachment" "logs" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs"
resource "aws_appsync_api_key" "example" {
api_id = aws_appsync_graphql_api.example.id
expires = "2020-12-31T23:00:00Z"
}
Parameters
-
api_id
required - string -
description
optional - string -
expires
optional - string -
id
optional computed - string -
key
optional computed - string
Explanation in Terraform Registry
Provides an AppSync API Key.
AWS::AppSync::ApiKey (CloudFormation)
The ApiKey in AppSync can be configured in CloudFormation with the resource name AWS::AppSync::ApiKey
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
Description
optional - String -
ApiKeyId
optional - String -
Expires
optional - Double -
ApiId
required - String
Explanation in CloudFormation Registry
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.
Frequently asked questions
What is AWS AppSync API Key?
AWS AppSync API Key is a resource for AppSync of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS AppSync API Key?
For Terraform, the mikamakusa/terraform, asrkata/SebastianUA-terraform and SebastianUA/terraform source code examples are useful. See the Terraform Example section for further details.