From 2099c5ba42f4f1918f31cc5afdeddc8ad8d35ed8 Mon Sep 17 00:00:00 2001 From: lexwong Date: Tue, 24 Sep 2019 15:58:50 +0800 Subject: [PATCH] =?UTF-8?q?imporve(oss=20object):=20update=20the=20module?= =?UTF-8?q?=20to=20the=20format=20of=20the=20new=20version.=C2=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/upload-to-oss/main.tf | 7 ++++--- examples/upload-to-oss/versions.tf | 4 ++++ main.tf | 13 ++++++++++--- outputs.tf | 5 +++-- variables.tf | 12 +++++++++--- versions.tf | 4 ++++ 6 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 examples/upload-to-oss/versions.tf create mode 100644 versions.tf diff --git a/examples/upload-to-oss/main.tf b/examples/upload-to-oss/main.tf index b49e096..16cd2f7 100644 --- a/examples/upload-to-oss/main.tf +++ b/examples/upload-to-oss/main.tf @@ -1,13 +1,14 @@ module "oss_bucket" { - source = "terraform-alicloud-modules/oss-bucket/alicloud" + source = "terraform-alicloud-modules/oss-bucket/alicloud" bucket_name = "bucket-terraform-20181111" - acl = "private" + acl = "private" } // Upload file without encryption module "oss-object" { source = "../.." - bucketName = "${module.oss_bucket.this_oss_bucket_id}" + bucketName = module.oss_bucket.this_oss_bucket_id sourceFile = "test.txt" object-key = "test-1.txt" } + diff --git a/examples/upload-to-oss/versions.tf b/examples/upload-to-oss/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/examples/upload-to-oss/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +} diff --git a/main.tf b/main.tf index af43353..03fded0 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,12 @@ +provider "alicloud" { + version = ">=1.56.0" + region = var.region != "" ? var.region : null + configuration_source = "terraform-alicloud-modules/oss-object" +} + resource "alicloud_oss_bucket_object" "this" { - bucket = "${var.bucketName}" - key = "${var.object-key}" - source = "${var.sourceFile}" + bucket = var.bucketName + key = var.object-key + source = var.sourceFile } + diff --git a/outputs.tf b/outputs.tf index 07bfc12..1b4cb0a 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,7 +1,8 @@ output "this_dest_file" { - value = "${element(concat(alicloud_oss_bucket_object.this.*.key, list("")), 0)}" + value = element(concat(alicloud_oss_bucket_object.this.*.key, [""]), 0) } output "this_source_file" { - value = "${element(concat(alicloud_oss_bucket_object.this.*.source, list("")), 0)}" + value = element(concat(alicloud_oss_bucket_object.this.*.source, [""]), 0) } + diff --git a/variables.tf b/variables.tf index 6907bfe..0577c79 100644 --- a/variables.tf +++ b/variables.tf @@ -1,11 +1,17 @@ +variable "region" { + description = "The region used to launch this module resources." + default = "" +} + variable "bucketName" { - type = "string" + type = string } variable "object-key" { - type = "string" + type = string } variable "sourceFile" { - type = "string" + type = string } + diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..ac97c6a --- /dev/null +++ b/versions.tf @@ -0,0 +1,4 @@ + +terraform { + required_version = ">= 0.12" +}