Home

Awesome

<!-- markdownlint-disable -->

<a href="https://cpco.io/homepage"><img src="https://github.com/cloudposse/terraform-aws-s3-bucket/blob/main/.github/banner.png?raw=true" alt="Project Banner"/></a><br/> <p align="right"> <a href="https://github.com/cloudposse/terraform-aws-s3-bucket/actions"><img src="https://github.com/cloudposse/terraform-aws-s3-bucket/workflows/test/badge.svg?branch=master" alt="GitHub Action Tests"/></a><a href="https://github.com/cloudposse/terraform-aws-s3-bucket/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/terraform-aws-s3-bucket.svg?style=for-the-badge" alt="Latest Release"/></a><a href="https://github.com/cloudposse/terraform-aws-s3-bucket/commits"><img src="https://img.shields.io/github/last-commit/cloudposse/terraform-aws-s3-bucket.svg?style=for-the-badge" alt="Last Updated"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"/></a></p>

<!-- markdownlint-restore --> <!-- ** DO NOT EDIT THIS FILE ** ** This file was automatically generated by the `cloudposse/build-harness`. ** 1) Make all changes to `README.yaml` ** 2) Run `make init` (you only need to do this once) ** 3) Run`make readme` to rebuild this file. ** ** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.) ** -->

This module creates an S3 bucket with support for versioning, lifecycles, object locks, replication, encryption, ACL, bucket object policies, and static website hosting.

For backward compatibility, it sets the S3 bucket ACL to private and the s3_object_ownership to ObjectWriter. Moving forward, setting s3_object_ownership to BucketOwnerEnforced is recommended, and doing so automatically disables the ACL.

This module blocks public access to the bucket by default. See block_public_acls, block_public_policy, ignore_public_acls, and restrict_public_buckets to change the settings. See AWS documentation for more details.

This module can optionally create an IAM User with access to the S3 bucket. This is inherently insecure in that to enable anyone to become the User, access keys must be generated, and anything generated by Terraform is stored unencrypted in the Terraform state. See the Terraform documentation for more details

The best way to grant access to the bucket is to grant one or more IAM Roles access to the bucket via privileged_principal_arns. This IAM Role can be assumed by EC2 instances via their Instance Profile, or Kubernetes (EKS) services using IRSA. Entities outside of AWS can assume the Role via OIDC. (See this example of connecting GitHub to enable GitHub actions to assume AWS IAM roles, or use this Cloud Posse component if you are already using the Cloud Posse reference architecture.)

If neither of those approaches work, then as a last resort you can set user_enabled = true and this module will provision a basic IAM user with permissions to access the bucket. We do not recommend creating IAM users this way for any other purpose.

If an IAM user is created, the IAM user name is constructed using terraform-null-label and some input is required. The simplest input is name. By default the name will be converted to lower case and all non-alphanumeric characters except for hyphen will be removed. See the documentation for terraform-null-label to learn how to override these defaults if desired.

If an AWS Access Key is created, it is stored either in SSM Parameter Store or is provided as a module output, but not both. Using SSM Parameter Store is recommended because that will keep the secret from being easily accessible via Terraform remote state lookup, but the key will still be stored unencrypted in the Terraform state in any case.

[!TIP]

πŸ‘½ Use Atmos with Terraform

Cloud Posse uses atmos to easily orchestrate multiple environments using Terraform. <br/> Works with Github Actions, Atlantis, or Spacelift.

<details> <summary><strong>Watch demo of using Atmos with Terraform</strong></summary> <img src="https://github.com/cloudposse/atmos/blob/main/docs/demo.gif?raw=true"/><br/> <i>Example of running <a href="https://atmos.tools"><code>atmos</code></a> to manage infrastructure from our <a href="https://atmos.tools/quick-start/">Quick Start</a> tutorial.</i> </detalis>

Usage

Using BucketOwnerEnforced

module "s3_bucket" {
  source = "cloudposse/s3-bucket/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version = "x.x.x"
  name                     = "app"
  stage                    = "test"
  namespace                = "eg"

  s3_object_ownership      = "BucketOwnerEnforced"
  enabled                  = true
  user_enabled             = false
  versioning_enabled       = false

  privileged_principal_actions   = ["s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation"]
  privileged_principal_arns      = [
    {
      (local.deployment_iam_role_arn) = [""]
    },
    {
      (local.additional_deployment_iam_role_arn) = ["prefix1/", "prefix2/"]
    }
  ]
}

Configuring S3 storage lifecycle:

locals {
  lifecycle_configuration_rules = [{
    enabled = true # bool
    id      = "v2rule"

    abort_incomplete_multipart_upload_days = 1 # number

    filter_and = null
    expiration = {
      days = 120 # integer > 0
    }
    noncurrent_version_expiration = {
      newer_noncurrent_versions = 3  # integer > 0
      noncurrent_days           = 60 # integer >= 0
    }
    transition = [{
      days          = 30            # integer >= 0
      storage_class = "STANDARD_IA" # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.
      },
      {
        days          = 60           # integer >= 0
        storage_class = "ONEZONE_IA" # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.
    }]
    noncurrent_version_transition = [{
      newer_noncurrent_versions = 3            # integer >= 0
      noncurrent_days           = 30           # integer >= 0
      storage_class             = "ONEZONE_IA" # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.
    }]
  }]
}

Allowing specific principal ARNs to perform actions on the bucket:

module "s3_bucket" {
  source = "cloudposse/s3-bucket/aws"
  # Cloud Posse recommends pinning every module to a specific version
  # version = "x.x.x"
  s3_object_ownership      = "BucketOwnerEnforced"
  enabled                  = true
  user_enabled             = true
  versioning_enabled       = false
  allowed_bucket_actions   = ["s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation"]
  name                     = "app"
  stage                    = "test"
  namespace                = "eg"

  privileged_principal_arns = [
  {
    "arn:aws:iam::123456789012:role/principal1" = ["prefix1/", "prefix2/"]
  }, {
    "arn:aws:iam::123456789012:role/principal2" = [""]
  }]
  privileged_principal_actions = [
    "s3:PutObject", 
    "s3:PutObjectAcl", 
    "s3:GetObject", 
    "s3:DeleteObject", 
    "s3:ListBucket", 
    "s3:ListBucketMultipartUploads", 
    "s3:GetBucketLocation", 
    "s3:AbortMultipartUpload"
  ]
}

[!IMPORTANT] In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic approach for updating versions to avoid unexpected changes.

<!-- markdownlint-disable -->

Makefile Targets

Available targets:

  help                                Help screen
  help/all                            Display help for all targets
  help/short                          This help short screen
  lint                                Lint terraform code
  test/%                              Run Terraform commands in the examples/complete folder; e.g. make test/plan

<!-- markdownlint-restore --> <!-- markdownlint-disable -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 1.3.0
<a name="requirement_aws"></a> aws>= 4.9.0
<a name="requirement_time"></a> time>= 0.7

Providers

NameVersion
<a name="provider_aws"></a> aws>= 4.9.0
<a name="provider_time"></a> time>= 0.7

Modules

NameSourceVersion
<a name="module_s3_user"></a> s3_usercloudposse/iam-s3-user/aws1.2.0
<a name="module_this"></a> thiscloudposse/label/null0.25.0

Resources

NameType
aws_iam_policy.replicationresource
aws_iam_role.replicationresource
aws_iam_role_policy_attachment.replicationresource
aws_s3_bucket.defaultresource
aws_s3_bucket_accelerate_configuration.defaultresource
aws_s3_bucket_acl.defaultresource
aws_s3_bucket_cors_configuration.defaultresource
aws_s3_bucket_lifecycle_configuration.defaultresource
aws_s3_bucket_logging.defaultresource
aws_s3_bucket_notification.bucket_notificationresource
aws_s3_bucket_object_lock_configuration.defaultresource
aws_s3_bucket_ownership_controls.defaultresource
aws_s3_bucket_policy.defaultresource
aws_s3_bucket_public_access_block.defaultresource
aws_s3_bucket_replication_configuration.defaultresource
aws_s3_bucket_request_payment_configuration.defaultresource
aws_s3_bucket_server_side_encryption_configuration.defaultresource
aws_s3_bucket_versioning.defaultresource
aws_s3_bucket_website_configuration.defaultresource
aws_s3_bucket_website_configuration.redirectresource
aws_s3_directory_bucket.defaultresource
time_sleep.wait_for_aws_s3_bucket_settingsresource
aws_canonical_user_id.defaultdata source
aws_iam_policy_document.aggregated_policydata source
aws_iam_policy_document.bucket_policydata source
aws_iam_policy_document.replicationdata source
aws_iam_policy_document.replication_stsdata source
aws_partition.currentdata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_access_key_enabled"></a> access_key_enabledSet to true to create an IAM Access Key for the created IAM userbooltrueno
<a name="input_acl"></a> aclThe canned ACL to apply.<br/>Deprecated by AWS in favor of bucket policies.<br/>Automatically disabled if s3_object_ownership is set to "BucketOwnerEnforced".<br/>Defaults to "private" for backwards compatibility, but we recommend setting s3_object_ownership to "BucketOwnerEnforced" instead.string"private"no
<a name="input_additional_tag_map"></a> additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration.map(string){}no
<a name="input_allow_encrypted_uploads_only"></a> allow_encrypted_uploads_onlySet to true to prevent uploads of unencrypted objects to S3 bucketboolfalseno
<a name="input_allow_ssl_requests_only"></a> allow_ssl_requests_onlySet to true to require requests to use Secure Socket Layer (HTTPS/SSL). This will explicitly deny access to HTTP requestsboolfalseno
<a name="input_allowed_bucket_actions"></a> allowed_bucket_actionsList of actions the user is permitted to perform on the S3 bucketlist(string)<pre>[<br/> "s3:PutObject",<br/> "s3:PutObjectAcl",<br/> "s3:GetObject",<br/> "s3:DeleteObject",<br/> "s3:ListBucket",<br/> "s3:ListBucketMultipartUploads",<br/> "s3:GetBucketLocation",<br/> "s3:AbortMultipartUpload"<br/>]</pre>no
<a name="input_attributes"></a> attributesID element. Additional attributes (e.g. workers or cluster) to add to id,<br/>in the order they appear in the list. New attributes are appended to the<br/>end of the list. The elements of the list are joined by the delimiter<br/>and treated as a single ID element.list(string)[]no
<a name="input_availability_zone_id"></a> availability_zone_idThe ID of the availability zone.string""no
<a name="input_block_public_acls"></a> block_public_aclsSet to false to disable the blocking of new public access lists on the bucketbooltrueno
<a name="input_block_public_policy"></a> block_public_policySet to false to disable the blocking of new public policies on the bucketbooltrueno
<a name="input_bucket_key_enabled"></a> bucket_key_enabledSet this to true to use Amazon S3 Bucket Keys for SSE-KMS, which may or may not reduce the number of AWS KMS requests.<br/>For more information, see: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-key.htmlboolfalseno
<a name="input_bucket_name"></a> bucket_nameBucket name. If provided, the bucket will be created with this name instead of generating the name from the contextstringnullno
<a name="input_context"></a> contextSingle object for setting entire context at once.<br/>See description of individual variables for details.<br/>Leave string and numeric variables as null to use default value.<br/>Individual variable settings (non-null) override settings in context object,<br/>except for attributes, tags, and additional_tag_map, which are merged.any<pre>{<br/> "additional_tag_map": {},<br/> "attributes": [],<br/> "delimiter": null,<br/> "descriptor_formats": {},<br/> "enabled": true,<br/> "environment": null,<br/> "id_length_limit": null,<br/> "label_key_case": null,<br/> "label_order": [],<br/> "label_value_case": null,<br/> "labels_as_tags": [<br/> "unset"<br/> ],<br/> "name": null,<br/> "namespace": null,<br/> "regex_replace_chars": null,<br/> "stage": null,<br/> "tags": {},<br/> "tenant": null<br/>}</pre>no
<a name="input_cors_configuration"></a> cors_configurationSpecifies the allowed headers, methods, origins and exposed headers when using CORS on this bucket<pre>list(object({<br/> id = optional(string)<br/> allowed_headers = optional(list(string))<br/> allowed_methods = optional(list(string))<br/> allowed_origins = optional(list(string))<br/> expose_headers = optional(list(string))<br/> max_age_seconds = optional(number)<br/> }))</pre>[]no
<a name="input_create_s3_directory_bucket"></a> create_s3_directory_bucketControl the creation of the S3 directory bucket. Set to true to create the bucket, false to skip.boolfalseno
<a name="input_delimiter"></a> delimiterDelimiter to be used between ID elements.<br/>Defaults to - (hyphen). Set to "" to use no delimiter at all.stringnullno
<a name="input_descriptor_formats"></a> descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.<br/>Map of maps. Keys are names of descriptors. Values are maps of the form<br/>{<br/> format = string<br/> labels = list(string)<br/>}<br/>(Type is any so the map values can later be enhanced to provide additional options.)<br/>format is a Terraform format string to be passed to the format() function.<br/>labels is a list of labels, in order, to pass to format() function.<br/>Label values will be normalized before being passed to format() so they will be<br/>identical to how they appear in id.<br/>Default is {} (descriptors output will be empty).any{}no
<a name="input_enabled"></a> enabledSet to false to prevent the module from creating any resourcesboolnullno
<a name="input_environment"></a> environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
<a name="input_event_notification_details"></a> event_notification_detailsS3 event notification details<pre>object({<br/> enabled = bool<br/> eventbridge = optional(bool, false)<br/> lambda_list = optional(list(object({<br/> lambda_function_arn = string<br/> events = optional(list(string), ["s3:ObjectCreated:"])<br/> filter_prefix = string<br/> filter_suffix = string<br/> })), [])<br/><br/> queue_list = optional(list(object({<br/> queue_arn = string<br/> events = optional(list(string), ["s3:ObjectCreated:"])<br/> })), [])<br/><br/> topic_list = optional(list(object({<br/> topic_arn = string<br/> events = optional(list(string), ["s3:ObjectCreated:*"])<br/> })), [])<br/> })</pre><pre>{<br/> "enabled": false<br/>}</pre>no
<a name="input_expected_bucket_owner"></a> expected_bucket_ownerAccount ID of the expected bucket owner. <br/>More information: https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-owner-condition.htmlstringnullno
<a name="input_force_destroy"></a> force_destroyWhen true, permits a non-empty S3 bucket to be deleted by first deleting all objects in the bucket.<br/>THESE OBJECTS ARE NOT RECOVERABLE even if they were versioned and stored in Glacier.boolfalseno
<a name="input_grants"></a> grantsA list of policy grants for the bucket, taking a list of permissions.<br/>Conflicts with acl. Set acl to null to use this.<br/>Deprecated by AWS in favor of bucket policies.<br/>Automatically disabled if s3_object_ownership is set to "BucketOwnerEnforced".<pre>list(object({<br/> id = string<br/> type = string<br/> permissions = list(string)<br/> uri = string<br/> }))</pre>[]no
<a name="input_id_length_limit"></a> id_length_limitLimit id to this many characters (minimum 6).<br/>Set to 0 for unlimited length.<br/>Set to null for keep the existing setting, which defaults to 0.<br/>Does not affect id_full.numbernullno
<a name="input_ignore_public_acls"></a> ignore_public_aclsSet to false to disable the ignoring of public access lists on the bucketbooltrueno
<a name="input_kms_master_key_arn"></a> kms_master_key_arnThe AWS KMS master key ARN used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kmsstring""no
<a name="input_label_key_case"></a> label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.<br/>Does not affect keys of tags passed in via the tags input.<br/>Possible values: lower, title, upper.<br/>Default value: title.stringnullno
<a name="input_label_order"></a> label_orderThe order in which the labels (ID elements) appear in the id.<br/>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br/>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.list(string)nullno
<a name="input_label_value_case"></a> label_value_caseControls the letter case of ID elements (labels) as included in id,<br/>set as tag values, and output by this module individually.<br/>Does not affect values of tags passed in via the tags input.<br/>Possible values: lower, title, upper and none (no transformation).<br/>Set this to title and set delimiter to "" to yield Pascal Case IDs.<br/>Default value: lower.stringnullno
<a name="input_labels_as_tags"></a> labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.<br/>Default is to include all labels.<br/>Tags with empty values will not be included in the tags output.<br/>Set to [] to suppress all generated tags.<br/>Notes:<br/> The value of the name tag, if included, will be the id, not the name.<br/> Unlike other null-label inputs, the initial setting of labels_as_tags cannot be<br/> changed in later chained modules. Attempts to change it will be silently ignored.set(string)<pre>[<br/> "default"<br/>]</pre>no
<a name="input_lifecycle_configuration_rules"></a> lifecycle_configuration_rulesA list of lifecycle V2 rules<pre>list(object({<br/> enabled = optional(bool, true)<br/> id = string<br/><br/> abort_incomplete_multipart_upload_days = optional(number)<br/><br/> # filter_and is the and configuration block inside the filter configuration.<br/> # This is the only place you should specify a prefix.<br/> filter_and = optional(object({<br/> object_size_greater_than = optional(number) # integer >= 0<br/> object_size_less_than = optional(number) # integer >= 1<br/> prefix = optional(string)<br/> tags = optional(map(string), {})<br/> }))<br/> expiration = optional(object({<br/> date = optional(string) # string, RFC3339 time format, GMT<br/> days = optional(number) # integer > 0<br/> expired_object_delete_marker = optional(bool)<br/> }))<br/> noncurrent_version_expiration = optional(object({<br/> newer_noncurrent_versions = optional(number) # integer > 0<br/> noncurrent_days = optional(number) # integer >= 0<br/> }))<br/> transition = optional(list(object({<br/> date = optional(string) # string, RFC3339 time format, GMT<br/> days = optional(number) # integer > 0<br/> storage_class = optional(string)<br/> # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.<br/> })), [])<br/><br/> noncurrent_version_transition = optional(list(object({<br/> newer_noncurrent_versions = optional(number) # integer >= 0<br/> noncurrent_days = optional(number) # integer >= 0<br/> storage_class = optional(string)<br/> # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.<br/> })), [])<br/> }))</pre>[]no
<a name="input_lifecycle_rule_ids"></a> lifecycle_rule_idsDEPRECATED (use lifecycle_configuration_rules): A list of IDs to assign to corresponding lifecycle_ruleslist(string)[]no
<a name="input_lifecycle_rules"></a> lifecycle_rulesDEPRECATED (use lifecycle_configuration_rules): A list of lifecycle rules<pre>list(object({<br/> prefix = string<br/> enabled = bool<br/> tags = map(string)<br/><br/> enable_glacier_transition = bool<br/> enable_deeparchive_transition = bool<br/> enable_standard_ia_transition = bool<br/> enable_current_object_expiration = bool<br/> enable_noncurrent_version_expiration = bool<br/><br/> abort_incomplete_multipart_upload_days = number<br/> noncurrent_version_glacier_transition_days = number<br/> noncurrent_version_deeparchive_transition_days = number<br/> noncurrent_version_expiration_days = number<br/><br/> standard_transition_days = number<br/> glacier_transition_days = number<br/> deeparchive_transition_days = number<br/> expiration_days = number<br/> }))</pre>nullno
<a name="input_logging"></a> loggingBucket access logging configuration. Empty list for no logging, list of 1 to enable logging.<pre>list(object({<br/> bucket_name = string<br/> prefix = string<br/> }))</pre>[]no
<a name="input_minimum_tls_version"></a> minimum_tls_versionSet the minimum TLS version for in-transit trafficstringnullno
<a name="input_name"></a> nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br/>This is the only ID element not also included as a tag.<br/>The "name" tag is set to the full id string. There is no tag with the value of the name input.stringnullno
<a name="input_namespace"></a> namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
<a name="input_object_lock_configuration"></a> object_lock_configurationA configuration for S3 object locking. With S3 Object Lock, you can store objects using a write once, read many (WORM) model. Object Lock can help prevent objects from being deleted or overwritten for a fixed amount of time or indefinitely.<pre>object({<br/> mode = string # Valid values are GOVERNANCE and COMPLIANCE.<br/> days = number<br/> years = number<br/> })</pre>nullno
<a name="input_privileged_principal_actions"></a> privileged_principal_actionsList of actions to permit privileged_principal_arns to perform on bucket and bucket prefixes (see privileged_principal_arns)list(string)[]no
<a name="input_privileged_principal_arns"></a> privileged_principal_arnsList of maps. Each map has a key, an IAM Principal ARN, whose associated value is<br/>a list of S3 path prefixes to grant privileged_principal_actions permissions for that principal,<br/>in addition to the bucket itself, which is automatically included. Prefixes should not begin with '/'.list(map(list(string)))[]no
<a name="input_regex_replace_chars"></a> regex_replace_charsTerraform regular expression (regex) string.<br/>Characters matching the regex will be removed from the ID elements.<br/>If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.stringnullno
<a name="input_replication_rules"></a> replication_rulesDEPRECATED (use s3_replication_rules): Specifies the replication rules for S3 bucket replication if enabled. You must also set s3_replication_enabled to true.list(any)nullno
<a name="input_restrict_public_buckets"></a> restrict_public_bucketsSet to false to disable the restricting of making the bucket publicbooltrueno
<a name="input_s3_object_ownership"></a> s3_object_ownershipSpecifies the S3 object ownership control.<br/>Valid values are ObjectWriter, BucketOwnerPreferred, and 'BucketOwnerEnforced'.<br/>Defaults to "ObjectWriter" for backwards compatibility, but we recommend setting "BucketOwnerEnforced" instead.string"ObjectWriter"no
<a name="input_s3_replica_bucket_arn"></a> s3_replica_bucket_arnA single S3 bucket ARN to use for all replication rules.<br/>Note: The destination bucket can be specified in the replication rule itself<br/>(which allows for multiple destinations), in which case it will take precedence over this variable.string""no
<a name="input_s3_replication_enabled"></a> s3_replication_enabledSet this to true and specify s3_replication_rules to enable replication. versioning_enabled must also be true.boolfalseno
<a name="input_s3_replication_permissions_boundary_arn"></a> s3_replication_permissions_boundary_arnPermissions boundary ARN for the created IAM replication role.stringnullno
<a name="input_s3_replication_rules"></a> s3_replication_rulesSpecifies the replication rules for S3 bucket replication if enabled. You must also set s3_replication_enabled to true.<pre>list(object({<br/> id = optional(string)<br/> priority = optional(number)<br/> prefix = optional(string)<br/> status = optional(string, "Enabled")<br/> # delete_marker_replication { status } had been flattened for convenience<br/> delete_marker_replication_status = optional(string, "Disabled")<br/> # Add the configuration as it appears in the resource, for consistency<br/> # this nested version takes precedence if both are provided.<br/> delete_marker_replication = optional(object({<br/> status = string<br/> }))<br/><br/> # destination_bucket is specified here rather than inside the destination object because before optional<br/> # attributes, it made it easier to work with the Terraform type system and create a list of consistent type.<br/> # It is preserved for backward compatibility, but the nested version takes priority if both are provided.<br/> destination_bucket = optional(string) # destination bucket ARN, overrides s3_replica_bucket_arn<br/><br/> destination = object({<br/> bucket = optional(string) # destination bucket ARN, overrides s3_replica_bucket_arn<br/> storage_class = optional(string, "STANDARD")<br/> # replica_kms_key_id at this level is for backward compatibility, and is overridden by the one in encryption_configuration<br/> replica_kms_key_id = optional(string, "")<br/> encryption_configuration = optional(object({<br/> replica_kms_key_id = string<br/> }))<br/> access_control_translation = optional(object({<br/> owner = string<br/> }))<br/> # account_id is for backward compatibility, overridden by account<br/> account_id = optional(string)<br/> account = optional(string)<br/> # For convenience, specifying either metrics or replication_time enables both<br/> metrics = optional(object({<br/> event_threshold = optional(object({<br/> minutes = optional(number, 15) # Currently 15 is the only valid number<br/> }), { minutes = 15 })<br/> status = optional(string, "Enabled")<br/> }), { status = "Disabled" })<br/> # To preserve backward compatibility, Replication Time Control (RTC) is automatically enabled<br/> # when metrics are enabled. To enable metrics without RTC, you must explicitly configure<br/> # replication_time.status = "Disabled".<br/> replication_time = optional(object({<br/> time = optional(object({<br/> minutes = optional(number, 15) # Currently 15 is the only valid number<br/> }), { minutes = 15 })<br/> status = optional(string)<br/> }))<br/> })<br/><br/> source_selection_criteria = optional(object({<br/> replica_modifications = optional(object({<br/> status = string # Either Enabled or Disabled<br/> }))<br/> sse_kms_encrypted_objects = optional(object({<br/> status = optional(string)<br/> }))<br/> }))<br/> # filter.prefix overrides top level prefix<br/> filter = optional(object({<br/> prefix = optional(string)<br/> tags = optional(map(string), {})<br/> }))<br/> }))</pre>nullno
<a name="input_s3_replication_source_roles"></a> s3_replication_source_rolesCross-account IAM Role ARNs that will be allowed to perform S3 replication to this bucket (for replication within the same AWS account, it's not necessary to adjust the bucket policy).list(string)[]no
<a name="input_s3_request_payment_configuration"></a> s3_request_payment_configurationS3 request payment configuration<pre>object({<br/> enabled = bool<br/> expected_bucket_owner = optional(string)<br/> payer = string<br/> })</pre><pre>{<br/> "enabled": false,<br/> "payer": "BucketOwner"<br/>}</pre>no
<a name="input_source_ip_allow_list"></a> source_ip_allow_listList of IP addresses to allow to perform all actions to the bucketlist(string)[]no
<a name="input_source_policy_documents"></a> source_policy_documentsList of IAM policy documents (in JSON) that are merged together into the exported document.<br/>Statements defined in source_policy_documents must have unique SIDs.<br/>Statement having SIDs that match policy SIDs generated by this module will override them.list(string)[]no
<a name="input_sse_algorithm"></a> sse_algorithmThe server-side encryption algorithm to use. Valid values are AES256 and aws:kmsstring"AES256"no
<a name="input_ssm_base_path"></a> ssm_base_pathThe base path for SSM parameters where created IAM user's access key is storedstring"/s3_user/"no
<a name="input_stage"></a> stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
<a name="input_store_access_key_in_ssm"></a> store_access_key_in_ssmSet to true to store the created IAM user's access key in SSM Parameter Store,<br/>false to store them in Terraform state as outputs.<br/>Since Terraform state would contain the secrets in plaintext,<br/>use of SSM Parameter Store is recommended.boolfalseno
<a name="input_tags"></a> tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).<br/>Neither the tag keys nor the tag values will be modified by this module.map(string){}no
<a name="input_tenant"></a> tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno
<a name="input_transfer_acceleration_enabled"></a> transfer_acceleration_enabledSet this to true to enable S3 Transfer Acceleration for the bucket.<br/>Note: When this is set to false Terraform does not perform drift detection<br/>and will not disable Transfer Acceleration if it was enabled outside of Terraform.<br/>To disable it via Terraform, you must set this to true and then to false.<br/>Note: not all regions support Transfer Acceleration.boolfalseno
<a name="input_user_enabled"></a> user_enabledSet to true to create an IAM user with permission to access the bucketboolfalseno
<a name="input_user_permissions_boundary_arn"></a> user_permissions_boundary_arnPermission boundary ARN for the IAM user created to access the bucket.stringnullno
<a name="input_versioning_enabled"></a> versioning_enabledA state of versioning. Versioning is a means of keeping multiple variants of an object in the same bucketbooltrueno
<a name="input_website_configuration"></a> website_configurationSpecifies the static website hosting configuration object<pre>list(object({<br/> index_document = string<br/> error_document = string<br/> routing_rules = list(object({<br/> condition = object({<br/> http_error_code_returned_equals = string<br/> key_prefix_equals = string<br/> })<br/> redirect = object({<br/> host_name = string<br/> http_redirect_code = string<br/> protocol = string<br/> replace_key_prefix_with = string<br/> replace_key_with = string<br/> })<br/> }))<br/> }))</pre>[]no
<a name="input_website_redirect_all_requests_to"></a> website_redirect_all_requests_toIf provided, all website requests will be redirected to the specified host name and protocol<pre>list(object({<br/> host_name = string<br/> protocol = string<br/> }))</pre>[]no

Outputs

NameDescription
<a name="output_access_key_id"></a> access_key_idThe access key ID, if var.user_enabled && var.access_key_enabled.<br/>While sensitive, it does not need to be kept secret, so this is output regardless of var.store_access_key_in_ssm.
<a name="output_access_key_id_ssm_path"></a> access_key_id_ssm_pathThe SSM Path under which the S3 User's access key ID is stored
<a name="output_bucket_arn"></a> bucket_arnBucket ARN
<a name="output_bucket_domain_name"></a> bucket_domain_nameFQDN of bucket
<a name="output_bucket_id"></a> bucket_idBucket Name (aka ID)
<a name="output_bucket_region"></a> bucket_regionBucket region
<a name="output_bucket_regional_domain_name"></a> bucket_regional_domain_nameThe bucket region-specific domain name
<a name="output_bucket_website_domain"></a> bucket_website_domainThe bucket website domain, if website is enabled
<a name="output_bucket_website_endpoint"></a> bucket_website_endpointThe bucket website endpoint, if website is enabled
<a name="output_enabled"></a> enabledIs module enabled
<a name="output_replication_role_arn"></a> replication_role_arnThe ARN of the replication IAM Role
<a name="output_secret_access_key"></a> secret_access_keyThe secret access key will be output if created and not stored in SSM. However, the secret access key, if created,<br/>will be written to the Terraform state file unencrypted, regardless of any other settings.<br/>See the Terraform documentation for more details.
<a name="output_secret_access_key_ssm_path"></a> secret_access_key_ssm_pathThe SSM Path under which the S3 User's secret access key is stored
<a name="output_user_arn"></a> user_arnThe ARN assigned by AWS for the user
<a name="output_user_enabled"></a> user_enabledIs user creation enabled
<a name="output_user_name"></a> user_nameNormalized IAM user name
<a name="output_user_unique_id"></a> user_unique_idThe user unique ID assigned by AWS
<!-- markdownlint-restore -->

Related Projects

Check out these related projects.

[!TIP]

Use Terraform Reference Architectures for AWS

Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.

βœ… We build it together with your team.<br/> βœ… Your team owns everything.<br/> βœ… 100% Open Source and backed by fanatical support.<br/>

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-bucket&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

<details><summary>πŸ“š <strong>Learn More</strong></summary> <br/>

Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.

Your team can operate like a pro today.

Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.

Day-0: Your Foundation for Success

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-bucket&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

Day-2: Your Operational Mastery

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-bucket&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>

</details>

✨ Contributing

This project is under active development, and we encourage contributions from our community.

Many thanks to our outstanding contributors:

<a href="https://github.com/cloudposse/terraform-aws-s3-bucket/graphs/contributors"> <img src="https://contrib.rocks/image?repo=cloudposse/terraform-aws-s3-bucket&max=24" /> </a>

For πŸ› bug reports & feature requests, please use the issue tracker.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Review our Code of Conduct and Contributor Guidelines.
  2. Fork the repo on GitHub
  3. Clone the project to your own machine
  4. Commit changes to your own branch
  5. Push your work back up to your fork
  6. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

🌎 Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

πŸ“° Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week β€” and usually a 5-minute read.

πŸ“† Office Hours <a href="https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-bucket&utm_content=office_hours"><img src="https://img.cloudposse.com/fit-in/200x200/https://cloudposse.com/wp-content/uploads/2019/08/Powered-by-Zoom.png" align="right" /></a>

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you can’t find anywhere else. It's FREE for everyone!

License

<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="License"></a>

<details> <summary>Preamble to the Apache License, Version 2.0</summary> <br/> <br/>

Complete license is available in the LICENSE file.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
</details>

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright Β© 2017-2024 Cloud Posse, LLC

<a href="https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-bucket&utm_content=readme_footer_link"><img alt="README footer" src="https://cloudposse.com/readme/footer/img"/></a>

<img alt="Beacon" width="0" src="https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-s3-bucket?pixel&cs=github&cm=readme&an=terraform-aws-s3-bucket"/>