Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 137 additions & 45 deletions examples/tencentcloud-cos/main.tf
Original file line number Diff line number Diff line change
@@ -1,66 +1,158 @@
resource "tencentcloud_cos_bucket" "bucket" {
bucket = var.bucket-name
acl = var.acl
data "tencentcloud_user_info" "info" {}

cors_rules {
allowed_headers = ["*"]
allowed_methods = ["GET", "POST"]
allowed_origins = ["https://www.test.com"]
expose_headers = ["x-cos-test"]
max_age_seconds = 300
}
locals {
app_id = data.tencentcloud_user_info.info.app_id
uin = data.tencentcloud_user_info.info.uin
owner_uin = data.tencentcloud_user_info.info.owner_uin
region = "ap-guangzhou"
}

lifecycle_rules {
filter_prefix = "test/"
# Private Bucket
resource "tencentcloud_cos_bucket" "private_sbucket" {
bucket = "private-bucket-${local.app_id}"
acl = "private"
}

expiration {
days = 365
}
# Multiple available zone bucket
resource "tencentcloud_cos_bucket" "multi_zone_bucket" {
bucket = "multi-zone-bucket-${local.app_id}"
acl = "private"
multi_az = true
versioning_enable = true
force_clean = true
}

transition {
days = 30
storage_class = "STANDARD_IA"
}
# Using verbose acl
resource "tencentcloud_cos_bucket" "bucket_with_acl" {
bucket = "bucketwith-acl-${local.app_id}"
# NOTE: Specify the acl_body by the priority sequence of permission and user type with the following sequence: `CanonicalUser with READ`, `CanonicalUser with WRITE`, `CanonicalUser with FULL_CONTROL`, `CanonicalUser with WRITE_ACP`, `CanonicalUser with READ_ACP`, then specify the `Group` of permissions same as `CanonicalUser`.
acl_body = <<EOF
<AccessControlPolicy>
<Owner>
<ID>qcs::cam::uin/100022975249:uin/100022975249</ID>
<DisplayName>qcs::cam::uin/100022975249:uin/100022975249</DisplayName>
</Owner>
<AccessControlList>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
<URI>http://cam.qcloud.com/groups/global/AllUsers</URI>
</Grantee>
<Permission>READ</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
<ID>qcs::cam::uin/100022975249:uin/100022975249</ID>
<DisplayName>qcs::cam::uin/100022975249:uin/100022975249</DisplayName>
</Grantee>
<Permission>FULL_CONTROL</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
<ID>qcs::cam::uin/100022975249:uin/100022975249</ID>
<DisplayName>qcs::cam::uin/100022975249:uin/100022975249</DisplayName>
</Grantee>
<Permission>WRITE_ACP</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
<URI>http://cam.qcloud.com/groups/global/AllUsers</URI>
</Grantee>
<Permission>READ_ACP</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
<URI>http://cam.qcloud.com/groups/global/AllUsers</URI>
</Grantee>
<Permission>WRITE_ACP</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
<ID>qcs::cam::uin/100022975249:uin/100022975249</ID>
<DisplayName>qcs::cam::uin/100022975249:uin/100022975249</DisplayName>
</Grantee>
<Permission>READ</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
<ID>qcs::cam::uin/100022975249:uin/100022975249</ID>
<DisplayName>qcs::cam::uin/100022975249:uin/100022975249</DisplayName>
</Grantee>
<Permission>WRITE</Permission>
</Grant>
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
<URI>http://cam.qcloud.com/groups/global/AllUsers</URI>
</Grantee>
<Permission>FULL_CONTROL</Permission>
</Grant>
</AccessControlList>
</AccessControlPolicy>
EOF
}

transition {
days = 60
storage_class = "ARCHIVE"
}
}
# Static Website
resource "tencentcloud_cos_bucket" "bucket_with_static_website" {
bucket = "bucket-with-static-website-${local.app_id}"

website {
index_document = "index.html"
error_document = "error.html"
}

tags = {
"test" = "test"
}
}

resource "tencentcloud_cos_bucket_object" "object" {
bucket = tencentcloud_cos_bucket.bucket.bucket
key = var.object-name
content = var.object-content
content_type = "binary/octet-stream"
output "endpoint_test" {
value = tencentcloud_cos_bucket.bucket_with_static_website.website.0.endpoint
}

data "tencentcloud_cos_bucket_object" "data_object" {
bucket = tencentcloud_cos_bucket.bucket.id
key = tencentcloud_cos_bucket_object.object.key
# Using CORS
resource "tencentcloud_cos_bucket" "bucket_with_cors" {
bucket = "bucket-with-cors-${local.app_id}"
acl = "public-read-write"

cors_rules {
allowed_origins = ["http://*.abc.com"]
allowed_methods = ["PUT", "POST"]
allowed_headers = ["*"]
max_age_seconds = 300
expose_headers = ["Etag"]
}
}

data "tencentcloud_cos_buckets" "data_bucket" {
bucket_prefix = tencentcloud_cos_bucket.bucket.id
tags = tencentcloud_cos_bucket.bucket.tags
# Using object lifecycle
resource "tencentcloud_cos_bucket" "bucket_with_lifecycle" {
bucket = "bucket-with-lifecycle-${local.app_id}"
acl = "public-read-write"

lifecycle_rules {
filter_prefix = "path1/"

transition {
days = 30
storage_class = "STANDARD_IA"
}

expiration {
days = 90
}
}
}

resource "tencentcloud_cos_bucket_policy" "cos_policy" {
bucket = "mycos-1258798060"
policy = var.policy
# Using replication
resource "tencentcloud_cos_bucket" "bucket_replicate" {
bucket = "bucket-replicate-${local.app_id}"
acl = "private"
versioning_enable = true
}

resource "tencentcloud_cos_buckets" "verbose_acl_bucket" {
bucket_prefix = "mycos-1258798060"
acl_body = var.acl_body
resource "tencentcloud_cos_bucket" "bucket_with_replication" {
bucket = "bucket-with-replication-${local.app_id}"
acl = "private"
versioning_enable = true
replica_role = "qcs::cam::uin/${local.owner_uin}:uin/${local.uin}"
replica_rules {
id = "test-rep1"
status = "Enabled"
prefix = "dist"
destination_bucket = "qcs::cos:${local.region}::${tencentcloud_cos_bucket.bucket_replicate.bucket}"
}
}
70 changes: 0 additions & 70 deletions examples/tencentcloud-cos/variables.tf

This file was deleted.

79 changes: 79 additions & 0 deletions examples/tencentcloud-emr/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
data "tencentcloud_instance_types" "cvm4c8m" {
exclude_sold_out=true
cpu_core_count=4
memory_size=8
filter {
name = "instance-charge-type"
values = ["POSTPAID_BY_HOUR"]
}
filter {
name = "zone"
values = [var.availability_zone]
}
}

resource "tencentcloud_vpc" "emr_vpc" {
name = "emr-vpc"
cidr_block = "10.0.0.0/16"
}

resource "tencentcloud_subnet" "emr_subnet" {
availability_zone = var.availability_zone
name = "emr-subnets"
vpc_id = tencentcloud_vpc.emr_vpc.id
cidr_block = "10.0.20.0/28"
is_multicast = false
}

resource "tencentcloud_security_group" "emr_sg" {
name = "emr-sg"
description = "emr sg"
project_id = 0
}

resource "tencentcloud_emr_cluster" "emr_cluster" {
product_id=4
display_strategy="clusterList"
vpc_settings={
vpc_id=tencentcloud_vpc.emr_vpc.id
subnet_id=tencentcloud_subnet.emr_subnet.id
}
softwares=[
"zookeeper-3.6.1",
]
support_ha=0
instance_name="emr-cluster-test"
resource_spec {
master_resource_spec {
mem_size=8192
cpu=4
disk_size=100
disk_type="CLOUD_PREMIUM"
spec="CVM.${data.tencentcloud_instance_types.cvm4c8m.instance_types.0.family}"
storage_type=5
root_size=50
}
core_resource_spec {
mem_size=8192
cpu=4
disk_size=100
disk_type="CLOUD_PREMIUM"
spec="CVM.${data.tencentcloud_instance_types.cvm4c8m.instance_types.0.family}"
storage_type=5
root_size=50
}
master_count=1
core_count=2
}
login_settings={
password="Tencent@cloud123"
}
time_span=3600
time_unit="s"
pay_mode=0
placement={
zone=var.availability_zone
project_id=0
}
sg_id=tencentcloud_security_group.emr_sg.id
}
3 changes: 3 additions & 0 deletions examples/tencentcloud-emr/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "availability_zone" {
default = "ap-guangzhou-3"
}
3 changes: 3 additions & 0 deletions examples/tencentcloud-emr/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
Loading