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
resource "aws_storagegateway_cache" "this" {
disk_id = var.disk_id
gateway_arn = var.gateway_arn
}
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
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
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" {
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 파일공유#
Parameters
-
disk_id
required - string -
gateway_arn
required - string -
id
optional computed - string
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.
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.
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.
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.