Skip to content

Commit de8ce96

Browse files
MrWolongxiaozhu36
authored andcommitted
Removes the provider setting and improves the Readme
1 parent cd7dcff commit de8ce96

File tree

8 files changed

+132
-53
lines changed

8 files changed

+132
-53
lines changed

README-CN.md

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@ terraform-alicloud-mongodb
99
* [MongoDB 数据库实例 (mongodb instance)](https://www.terraform.io/docs/providers/alicloud/r/mongodb_instance.html)
1010
* [CmsAlarm 云监控实例 (cms_alarm)](https://www.terraform.io/docs/providers/alicloud/r/cms_alarm.html)
1111

12-
## Terraform 版本
13-
14-
本模板要求使用版本 Terraform 0.12 和阿里云 Provider 1.56.0+。
15-
1612
## 用法
1713

1814
#### 创建新的Mongodb实例
1915

2016
```hcl
2117
module "mongodb" {
2218
source = "terraform-alicloud-modules/mongodb/alicloud"
23-
region = "cn-shanghai"
2419
###################
2520
# MongoDB Instance
2621
###################
@@ -61,7 +56,6 @@ module "mongodb" {
6156
```hcl
6257
module "mongodb_example" {
6358
source = "terraform-alicloud-modules/mongodb/alicloud"
64-
region = "cn-shanghai"
6559
6660
###################
6761
# Mongodb Instance
@@ -97,8 +91,74 @@ module "mongodb_example" {
9791

9892

9993
## 注意事项
94+
本Module从版本v1.4.0开始已经移除掉如下的 provider 的显示设置:
95+
96+
```hcl
97+
provider "alicloud" {
98+
profile = var.profile != "" ? var.profile : null
99+
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
100+
region = var.region != "" ? var.region : null
101+
skip_region_validation = var.skip_region_validation
102+
configuration_source = "terraform-alicloud-modules/mongodb"
103+
}
104+
```
105+
106+
如果你依然想在Module中使用这个 provider 配置,你可以在调用Module的时候,指定一个特定的版本,比如 1.3.0:
107+
108+
```hcl
109+
module "mongodb" {
110+
source = "terraform-alicloud-modules/mongodb/alicloud"
111+
version = "1.3.0"
112+
region = "cn-shanghai"
113+
profile = "Your-Profile-Name"
114+
engine_version = "3.4"
115+
storage_engine = "RocksDB"
116+
// ...
117+
}
118+
```
119+
120+
如果你想对正在使用中的Module升级到 1.4.0 或者更高的版本,那么你可以在模板中显示定义一个系统过Region的provider:
121+
```hcl
122+
provider "alicloud" {
123+
region = "cn-shanghai"
124+
profile = "Your-Profile-Name"
125+
}
126+
module "mongodb" {
127+
source = "terraform-alicloud-modules/mongodb/alicloud"
128+
engine_version = "3.4"
129+
storage_engine = "RocksDB"
130+
// ...
131+
}
132+
```
133+
或者,如果你是多Region部署,你可以利用 `alias` 定义多个 provider,并在Module中显示指定这个provider:
134+
135+
```hcl
136+
provider "alicloud" {
137+
region = "cn-shanghai"
138+
profile = "Your-Profile-Name"
139+
alias = "sh"
140+
}
141+
module "mongodb" {
142+
source = "terraform-alicloud-modules/mongodb/alicloud"
143+
providers = {
144+
alicloud = alicloud.sh
145+
}
146+
engine_version = "3.4"
147+
storage_engine = "RocksDB"
148+
// ...
149+
}
150+
```
151+
152+
定义完provider之后,运行命令 `terraform init``terraform apply` 来让这个provider生效即可。
153+
154+
更多provider的使用细节,请移步[How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
155+
156+
## Terraform 版本
100157

101-
* 本 Module 使用的 AccessKey 和 SecretKey 可以直接从 `profile``shared_credentials_file` 中获取。如果未设置,可通过下载安装 [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) 后进行配置.
158+
| Name | Version |
159+
|------|---------|
160+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
161+
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.56.0 |
102162

103163
作者
104164
-------

README.md

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ These types of resources are supported:
1313

1414
----------------------
1515

16-
## Terraform versions
17-
18-
This module requires Terraform 0.12 and Terraform Provider Alicloud 1.56.0+.
1916

2017
## Usage
2118
-----
@@ -25,7 +22,6 @@ For new instance
2522
```hcl
2623
module "mongodb" {
2724
source = "terraform-alicloud-modules/mongodb/alicloud"
28-
region = "cn-shanghai"
2925
3026
#################
3127
# MongoDB Instance
@@ -67,7 +63,6 @@ For existing instance
6763
```hcl
6864
module "mongodb_example" {
6965
source = "terraform-alicloud-modules/mongodb/alicloud"
70-
region = "cn-shanghai"
7166
7267
###################
7368
# Mongodb Instance
@@ -102,10 +97,69 @@ module "mongodb_example" {
10297
* [mongodb-4.2-wiredtiger](https://github.com/terraform-alicloud-modules/terraform-alicloud-mongodb/tree/master/modules/mongodb-4.2-wiredtiger)
10398

10499
## Notes
100+
From the version v1.4.0, the module has removed the following `provider` setting:
101+
102+
```hcl
103+
provider "alicloud" {
104+
profile = var.profile != "" ? var.profile : null
105+
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
106+
region = var.region != "" ? var.region : null
107+
skip_region_validation = var.skip_region_validation
108+
configuration_source = "terraform-alicloud-modules/mongodb"
109+
}
110+
```
111+
112+
If you still want to use the `provider` setting to apply this module, you can specify a supported version, like 1.3.0:
113+
114+
```hcl
115+
module "mongodb" {
116+
source = "terraform-alicloud-modules/mongodb/alicloud"
117+
version = "1.3.0"
118+
region = "cn-shanghai"
119+
profile = "Your-Profile-Name"
120+
engine_version = "3.4"
121+
storage_engine = "RocksDB"
122+
// ...
123+
}
124+
```
125+
126+
If you want to upgrade the module to 1.4.0 or higher in-place, you can define a provider which same region with
127+
previous region:
128+
129+
```hcl
130+
provider "alicloud" {
131+
region = "cn-shanghai"
132+
profile = "Your-Profile-Name"
133+
}
134+
module "mongodb" {
135+
source = "terraform-alicloud-modules/mongodb/alicloud"
136+
engine_version = "3.4"
137+
storage_engine = "RocksDB"
138+
// ...
139+
}
140+
```
141+
or specify an alias provider with a defined region to the module using `providers`:
142+
143+
```hcl
144+
provider "alicloud" {
145+
region = "cn-shanghai"
146+
profile = "Your-Profile-Name"
147+
alias = "sh"
148+
}
149+
module "mongodb" {
150+
source = "terraform-alicloud-modules/mongodb/alicloud"
151+
providers = {
152+
alicloud = alicloud.sh
153+
}
154+
engine_version = "3.4"
155+
storage_engine = "RocksDB"
156+
// ...
157+
}
158+
```
105159

106-
* This module using AccessKey and SecretKey are from `profile` and `shared_credentials_file`.
107-
If you have not set them yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it.
160+
and then run `terraform init` and `terraform apply` to make the defined provider effect to the existing module state.
108161

162+
More details see [How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
109163

110164
Authors
111165
---------

main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
provider "alicloud" {
2-
profile = var.profile != "" ? var.profile : null
3-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
4-
region = var.region != "" ? var.region : null
5-
skip_region_validation = var.skip_region_validation
6-
configuration_source = "terraform-alicloud-modules/mongodb"
7-
}
81
locals {
92
this_instance_id = var.existing_instance_id != "" ? var.existing_instance_id : concat(alicloud_mongodb_instance.this.*.id, [""])[0]
103
create_more_resources = var.existing_instance_id != "" || var.create ? true : false

modules/mongodb-3.4-rocksdb/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
provider "alicloud" {
2-
profile = var.profile != "" ? var.profile : null
3-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
4-
region = var.region != "" ? var.region : null
5-
skip_region_validation = var.skip_region_validation
6-
configuration_source = "terraform-alicloud-modules/mongodb"
7-
}
81
locals {
92
engine_version = "3.4"
103
storage_engine = "RocksDB"

modules/mongodb-3.4-wiredtiger/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
provider "alicloud" {
2-
profile = var.profile != "" ? var.profile : null
3-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
4-
region = var.region != "" ? var.region : null
5-
skip_region_validation = var.skip_region_validation
6-
configuration_source = "terraform-alicloud-modules/mongodb"
7-
}
81
locals {
92
engine_version = "3.4"
103
storage_engine = "WiredTiger"

modules/mongodb-4.0-wiredtiger/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
provider "alicloud" {
2-
profile = var.profile != "" ? var.profile : null
3-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
4-
region = var.region != "" ? var.region : null
5-
skip_region_validation = var.skip_region_validation
6-
configuration_source = "terraform-alicloud-modules/mongodb"
7-
}
81
locals {
92
engine_version = "4.0"
103
storage_engine = "WiredTiger"

modules/mongodb-4.2-wiredtiger/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
provider "alicloud" {
2-
profile = var.profile != "" ? var.profile : null
3-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
4-
region = var.region != "" ? var.region : null
5-
skip_region_validation = var.skip_region_validation
6-
configuration_source = "terraform-alicloud-modules/mongodb"
7-
}
81
locals {
92
engine_version = "4.2"
103
storage_engine = "WiredTiger"

variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
# Provider
33
#################
44
variable "profile" {
5-
description = "The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable. "
5+
description = "(Deprecated from version 1.4.0) The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable. "
66
type = string
77
default = ""
88
}
99

1010
variable "shared_credentials_file" {
11-
description = "This is the path to the shared credentials file. If this is not set and a profile is specified, $HOME/.aliyun/config.json will be used. "
11+
description = "(Deprecated from version 1.4.0) This is the path to the shared credentials file. If this is not set and a profile is specified, $HOME/.aliyun/config.json will be used. "
1212
type = string
1313
default = ""
1414
}
1515

1616
variable "region" {
17-
description = "The region used to launch this module resources. "
17+
description = "(Deprecated from version 1.4.0) The region used to launch this module resources. "
1818
type = string
1919
default = ""
2020
}
2121

2222
variable "skip_region_validation" {
23-
description = "Skip static validation of region ID. Used by users of alternative AlibabaCloud-like APIs or users w/ access to regions that are not public (yet). "
23+
description = "(Deprecated from version 1.4.0) Skip static validation of region ID. Used by users of alternative AlibabaCloud-like APIs or users w/ access to regions that are not public (yet). "
2424
type = bool
2525
default = false
2626
}

0 commit comments

Comments
 (0)