AWS Amazon S3 Cache

This page shows how to write Terraform for Amazon S3 Cache and write them securely.

aws_storagegateway_cache (Terraform)

The Cache in Amazon S3 can be configured in Terraform with the resource name aws_storagegateway_cache. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L7
resource "aws_storagegateway_cache" "this" {
  disk_id     = var.disk_id
  gateway_arn = var.gateway_arn
}

storagegateway_cache.tf#L4
resource "aws_storagegateway_cache" "storagegateway_cache" {
  count = var.enable_storagegateway_cache ? 1 : 0

  gateway_arn = var.storagegateway_cache_gateway_arn != "" ? var.storagegateway_cache_gateway_arn : (var.enable_storagegateway_gateway ? aws_storagegateway_gateway.storagegateway_gateway[count.index].arn : null)
  disk_id     = var.storagegateway_cache_disk_id

storagegateway_cache.tf#L4
resource "aws_storagegateway_cache" "storagegateway_cache" {
  count = var.enable_storagegateway_cache ? 1 : 0

  gateway_arn = var.storagegateway_cache_gateway_arn != "" ? var.storagegateway_cache_gateway_arn : (var.enable_storagegateway_gateway ? aws_storagegateway_gateway.storagegateway_gateway[count.index].arn : null)
  disk_id     = var.storagegateway_cache_disk_id

main.tf#L28
resource "aws_storagegateway_cache" "this" {
  disk_id     = data.aws_storagegateway_local_disk.this.disk_id
  gateway_arn = aws_storagegateway_gateway.this.arn
}

resource "aws_cloudwatch_log_group" "storage_gateway" {
StorageGateway-ec2.tf#L45
resource "aws_storagegateway_cache" "storage-gateway-cache" {
  disk_id     = data.aws_storagegateway_local_disk.storage-gateway-data.id
  gateway_arn = aws_storagegateway_gateway.storage-gateway.arn
}

#nfs-file 파일공유#

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).

Parameters

Explanation in Terraform Registry

Manages an AWS Storage Gateway cache.

NOTE: The Storage Gateway API provides no method to remove a cache disk. Destroying this Terraform resource does not perform any Storage Gateway actions.

Tips: Best Practices for The Other AWS Amazon S3 Resources

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

risk-label

aws_s3_bucket_public_access_block

Ensure S3 bucket-level Public Access Block restricts public bucket policies

It is better to enable S3 bucket-level Public Access Block if you don't need public buckets.

risk-label

aws_s3_bucket

Ensure S3 bucket access policy is well configured

It is better to configure the S3 bucket access policy properly to limit it unless explicitly required.

Review your AWS Amazon S3 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.

CloudFormation Example

CloudFormation code does not have the related resource.

Frequently asked questions

What is AWS Amazon S3 Cache?

AWS Amazon S3 Cache is a resource for Amazon S3 of Amazon Web Service. Settings can be wrote in Terraform.

Where can I find the example code for the AWS Amazon S3 Cache?

For Terraform, the niveklabs/aws, asrkata/SebastianUA-terraform and SebastianUA/terraform source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.