Skip to content

Commit

Permalink
Merge pull request #571 from duplocloud/DUPLO-18045-multizone-s3
Browse files Browse the repository at this point in the history
Duplo-18045 TF: GCP: Add Terraform support to create bucket with multi region and region
  • Loading branch information
tahir-duplo authored Jul 9, 2024
2 parents 6fb40e9 + 000c085 commit d61c80c
Show file tree
Hide file tree
Showing 7 changed files with 590 additions and 0 deletions.
142 changes: 142 additions & 0 deletions docs/resources/gcp_s3_bucket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "duplocloud_gcp_s3_bucket Resource - terraform-provider-duplocloud"
subcategory: ""
description: |-
---

# duplocloud_gcp_s3_bucket (Resource)



## Example Usage

```terraform
resource "duplocloud_tenant" "myapp" {
account_name = "myapp"
plan_id = "default"
}
# Simple Example 1: Deploy an S3 bucket with hardened security settings.
resource "duplocloud_gcp_s3_bucket" "mydata" {
tenant_id = duplocloud_tenant.myapp.tenant_id
name = "mydata"
allow_public_access = false
enable_access_logs = true
enable_versioning = true
managed_policies = ["ssl"]
default_encryption {
method = "Sse" # For even stricter security, use "TenantKms" here.
}
}
# Simple Example 2: Deploy a hardened S3 bucket suitable for public website hosting.
resource "duplocloud_gcp_s3_bucket" "www" {
tenant_id = duplocloud_tenant.myapp.tenant_id
name = "website"
allow_public_access = true
enable_access_logs = true
enable_versioning = true
managed_policies = ["ssl"]
default_encryption {
method = "Sse"
}
}
# Simple Example 3: Deploy an S3 bucket to dersired region.
resource "duplocloud_s3_bucket" "mydata" {
tenant_id = duplocloud_tenant.myapp.tenant_id
name = "mydata"
# optional, if not provided, tenant region will be used
region = "us-west-2"
}
# Simple Example 4: Deploy an S3 bucket with multiple region.
resource "duplocloud_gcp_s3_bucket" "mydata" {
tenant_id = duplocloud_tenant.myapp.tenant_id
name = "mydata"
allow_public_access = true
enable_access_logs = true
enable_versioning = true
managed_policies = ["ssl"]
default_encryption {
method = "Sse" # For even stricter security, use "TenantKms" here.
}
location = "Asia" #pass region value (Asia/EU/US)to location to enable multi region
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) The short name of the S3 bucket. Duplo will add a prefix to the name. You can retrieve the full name from the `fullname` attribute.
- `tenant_id` (String) The GUID of the tenant that the S3 bucket will be created in.

### Optional

- `allow_public_access` (Boolean) Whether or not to remove the public access block from the bucket.
- `default_encryption` (Block List, Max: 1) Default encryption settings for objects uploaded to the bucket. (see [below for nested schema](#nestedblock--default_encryption))
- `enable_access_logs` (Boolean) Whether or not to enable access logs. When enabled, Duplo will send access logs to a centralized S3 bucket per plan.
- `enable_versioning` (Boolean) Whether or not to enable versioning.
- `location` (String) The location is to set multi region, applicable for gcp cloud.
- `managed_policies` (List of String) Duplo can manage your S3 bucket policy for you, based on simple list of policy keywords:

- `"ssl"`: Require SSL / HTTPS when accessing the bucket.
- `"ignore"`: If this key is present, Duplo will not manage your bucket policy.
- `region` (String) The region of the S3 bucket.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `arn` (String) The ARN of the S3 bucket.
- `domain_name` (String) The domain name of the S3 bucket.
- `fullname` (String) The full name of the S3 bucket.
- `id` (String) The ID of this resource.
- `tags` (List of Object) (see [below for nested schema](#nestedatt--tags))

<a id="nestedblock--default_encryption"></a>
### Nested Schema for `default_encryption`

Optional:

- `method` (String) Default encryption method. Must be one of: `None`, `Sse`, `AwsKms`, `TenantKms`. Defaults to `Sse`.


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `delete` (String)


<a id="nestedatt--tags"></a>
### Nested Schema for `tags`

Read-Only:

- `key` (String)
- `value` (String)

## Import

Import is supported using the following syntax:

```shell
# Example: Importing an existing S3 bucket
# - *TENANT_ID* is the tenant GUID
# - *SHORTNAME* is the short name of the S3 bucket (without the duploservices prefix)
#
terraform import duplocloud_gcp_s3_bucket.mybucket *TENANT_ID*/*SHORTNAME*
```
1 change: 1 addition & 0 deletions duplocloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func Provider() *schema.Provider {
"duplocloud_plan_waf": resourcePlanWaf(),
"duplocloud_plan_kms": resourcePlanKMS(),
"duplocloud_aws_apigateway_event": resourceAwsApiGatewayEvent(),
"duplocloud_gcp_s3_bucket": resourceGCPS3Bucket(),
},
DataSourcesMap: map[string]*schema.Resource{
"duplocloud_admin_aws_credentials": dataSourceAdminAwsCredentials(),
Expand Down
Loading

0 comments on commit d61c80c

Please sign in to comment.