AWS API Gateway Account

This page shows how to write Terraform and CloudFormation for API Gateway Account and write them securely.

aws_api_gateway_account (Terraform)

The Account in API Gateway can be configured in Terraform with the resource name aws_api_gateway_account. The following sections describe 4 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "aws_api_gateway_account" "settings" {
  cloudwatch_role_arn = aws_iam_role.api_gateway_role.arn
resource "aws_api_gateway_account" "cloudwatch" {
  cloudwatch_role_arn = aws_iam_role.api_gateway_cloudwatch.arn
resource "aws_api_gateway_account" "this" {
  cloudwatch_role_arn = var.cloudwatch_role_arn
resource "aws_api_gateway_account" "api_gateway_account" {
  count = var.enable_api_gateway_account ? 1 : 0

  cloudwatch_role_arn = var.api_gateway_account_cloudwatch_role_arn

  lifecycle {

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


Explanation in Terraform Registry

Provides a settings of an API Gateway Account. Settings is applied region-wide per provider block. -> Note: As there is no API method for deleting account settings or resetting it to defaults, destroying this resource will keep your account settings intact

Tips: Best Practices for The Other AWS API Gateway Resources

In addition to the aws_api_gateway_method_settings, AWS API Gateway has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.



Ensure that API Gateway stage-level cache is encrypted

It is better to enable the stage-level cache encryption which reduces the risk of data leakage.



Ensure to use modern TLS protocols

It is better to adopt TLS v1.2+.



Ensure to enable access logging of your API Gateway stage (v1)

It is better to enable the access logging of your API Gateway stage (v1).



Ensure that your API Gateway method blocks unwanted access

It is better that the API Gateway method does not allow public access.

Review your AWS API Gateway settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

AWS::ApiGateway::Account (CloudFormation)

The Account in ApiGateway can be configured in CloudFormation with the resource name AWS::ApiGateway::Account. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.


Explanation in CloudFormation Registry

The AWS::ApiGateway::Account resource specifies the IAM role that Amazon API Gateway uses to write API logs to Amazon CloudWatch Logs.

Important If an API Gateway resource has never been created in your AWS account, you must add a dependency on another API Gateway resource, such as an AWS::ApiGateway::RestApi or AWS::ApiGateway::ApiKey resource. If an API Gateway resource has been created in your AWS account, no dependency is required (even if the resource was deleted).

Frequently asked questions

What is AWS API Gateway Account?

AWS API Gateway Account is a resource for API Gateway of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS API Gateway Account?

For Terraform, the controlshift/terraform-aws-controlshift-redshift-sync, cicdenv/cicdenv and niveklabs/aws source code examples are useful. See the Terraform Example section for further details.