Skip to content

Commit 60b8861

Browse files
王超xiaozhu36
authored andcommitted
Removes the provider setting and improves the Readme
1 parent fa6efc9 commit 60b8861

File tree

16 files changed

+171
-94
lines changed

16 files changed

+171
-94
lines changed

README-CN.md

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ terraform-alicloud-rds-postgres
1414

1515
## Terraform 版本
1616

17-
本模板要求使用版本 Terraform 0.12 和阿里云 Provider 1.71.0+。
17+
| Name | Version |
18+
|------|---------|
19+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
20+
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.71.0 |
1821

1922
## 用法
2023

@@ -23,7 +26,6 @@ terraform-alicloud-rds-postgres
2326
```hcl
2427
module "postgres" {
2528
source = "terraform-alicloud-modules/rds-postgres/alicloud"
26-
region = "cn-hangzhou"
2729
2830
#################
2931
# Rds Instance
@@ -93,7 +95,6 @@ module "postgres" {
9395
```hcl
9496
module "postgres" {
9597
source = "terraform-alicloud-modules/rds-postgres/alicloud"
96-
region = "cn-beijing"
9798
9899
#################
99100
# Rds Instance
@@ -161,9 +162,74 @@ module "postgres" {
161162
* [postgres-12-basic 模块](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-12-basic)
162163

163164
## 注意事项
165+
本Module从版本v1.1.0开始已经移除掉如下的 provider 的显示设置:
166+
```hcl
167+
provider "alicloud" {
168+
profile = var.profile != "" ? var.profile : null
169+
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
170+
region = var.region != "" ? var.region : null
171+
skip_region_validation = var.skip_region_validation
172+
configuration_source = "terraform-alicloud-modules/rds-postgres"
173+
}
174+
```
175+
176+
如果你依然想在Module中使用这个 provider 配置,你可以在调用Module的时候,指定一个特定的版本,比如 1.0.0:
177+
178+
```hcl
179+
module "rds-postgres" {
180+
source = "terraform-alicloud-modules/rds-postgres/alicloud"
181+
version = "1.0.0"
182+
region = "cn-hangzhou"
183+
profile = "Your-Profile-Name"
184+
engine_version = "10.0"
185+
instance_storage = 20
186+
instance_charge_type = "Postpaid"
187+
vswitch_id = "vsw-bp1tili2u5kxxxxxx"
188+
instance_name = "PostgreSQLInstance"
189+
instance_type = "rds.pg.s1.small"
190+
}
191+
```
192+
如果你想对正在使用中的Module升级到 1.1.0 或者更高的版本,那么你可以在模板中显示定义一个相同Region的provider:
193+
```hcl
194+
provider "alicloud" {
195+
region = "cn-hangzhou"
196+
profile = "Your-Profile-Name"
197+
}
198+
module "rds-postgres" {
199+
source = "terraform-alicloud-modules/rds-postgres/alicloud"
200+
engine_version = "10.0"
201+
instance_storage = 20
202+
instance_charge_type = "Postpaid"
203+
vswitch_id = "vsw-bp1tili2u5kxxxxxx"
204+
instance_name = "PostgreSQLInstance"
205+
instance_type = "rds.pg.s1.small"
206+
}
207+
```
208+
或者,如果你是多Region部署,你可以利用 `alias` 定义多个 provider,并在Module中显示指定这个provider:
209+
210+
```hcl
211+
provider "alicloud" {
212+
region = "cn-hangzhou"
213+
profile = "Your-Profile-Name"
214+
alias = "hz"
215+
}
216+
module "rds-postgres" {
217+
source = "terraform-alicloud-modules/rds-postgres/alicloud"
218+
providers = {
219+
alicloud = alicloud.hz
220+
}
221+
engine_version = "10.0"
222+
instance_storage = 20
223+
instance_charge_type = "Postpaid"
224+
vswitch_id = "vsw-bp1tili2u5kxxxxxx"
225+
instance_name = "PostgreSQLInstance"
226+
instance_type = "rds.pg.s1.small"
227+
}
228+
```
164229

165-
* 本 Module 使用的 AccessKey 和 SecretKey 可以直接从 `profile``shared_credentials_file` 中获取。如果未设置,可通过下载安装 [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) 后进行配置
230+
定义完provider之后,运行命令 `terraform init``terraform apply` 来让这个provider生效即可
166231

232+
更多provider的使用细节,请移步[How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
167233

168234
提交问题
169235
------

README.md

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ These types of resources are supported:
1414
* [Alicloud_db_backup_policy](https://www.terraform.io/docs/providers/alicloud/r/db_backup_policy.html)
1515
* [alicloud_cms_alarm](https://www.terraform.io/docs/providers/alicloud/r/alarm_rule.html)
1616

17-
1817
## Terraform versions
1918

20-
This module requires Terraform 0.12 and Terraform Provider Alicloud 1.71.0+.
19+
| Name | Version |
20+
|------|---------|
21+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
22+
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | >= 1.71.0 |
2123

2224
## Usage
2325

@@ -26,7 +28,6 @@ For new instance
2628
```hcl
2729
module "postgres" {
2830
source = "terraform-alicloud-modules/rds-postgres/alicloud"
29-
region = "cn-hangzhou"
3031
3132
#################
3233
# Rds Instance
@@ -95,7 +96,6 @@ For existing instance
9596
```hcl
9697
module "postgres" {
9798
source = "terraform-alicloud-modules/rds-postgres/alicloud"
98-
region = "cn-beijing"
9999
100100
#################
101101
# Rds Instance
@@ -164,10 +164,77 @@ module "postgres" {
164164
* [postgres-12-basic](https://github.com/terraform-alicloud-modules/terraform-alicloud-rds-postgres/tree/master/modules/postgres-12-basic)
165165

166166
## Notes
167+
From the version v1.1.0, the module has removed the following `provider` setting:
168+
169+
```hcl
170+
provider "alicloud" {
171+
profile = var.profile != "" ? var.profile : null
172+
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
173+
region = var.region != "" ? var.region : null
174+
skip_region_validation = var.skip_region_validation
175+
configuration_source = "terraform-alicloud-modules/rds-postgres"
176+
}
177+
```
178+
179+
If you still want to use the `provider` setting to apply this module, you can specify a supported version, like 1.0.0:
180+
181+
```hcl
182+
module "rds-postgres" {
183+
source = "terraform-alicloud-modules/rds-postgres/alicloud"
184+
version = "1.0.0"
185+
region = "cn-hangzhou"
186+
profile = "Your-Profile-Name"
187+
engine_version = "10.0"
188+
instance_storage = 20
189+
instance_charge_type = "Postpaid"
190+
vswitch_id = "vsw-bp1tili2u5kxxxxxx"
191+
instance_name = "PostgreSQLInstance"
192+
instance_type = "rds.pg.s1.small"
193+
}
194+
```
195+
196+
If you want to upgrade the module to 1.1.0 or higher in-place, you can define a provider which same region with
197+
previous region:
198+
199+
```hcl
200+
provider "alicloud" {
201+
region = "cn-hangzhou"
202+
profile = "Your-Profile-Name"
203+
}
204+
module "rds-postgres" {
205+
source = "terraform-alicloud-modules/rds-postgres/alicloud"
206+
engine_version = "10.0"
207+
instance_storage = 20
208+
instance_charge_type = "Postpaid"
209+
vswitch_id = "vsw-bp1tili2u5kxxxxxx"
210+
instance_name = "PostgreSQLInstance"
211+
instance_type = "rds.pg.s1.small"
212+
}
213+
```
214+
or specify an alias provider with a defined region to the module using `providers`:
167215

168-
* This module using AccessKey and SecretKey are from 'profile' and 'shared_credentials_file'.
169-
If you have not set them yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it.
216+
```hcl
217+
provider "alicloud" {
218+
region = "cn-hangzhou"
219+
profile = "Your-Profile-Name"
220+
alias = "hz"
221+
}
222+
module "rds-postgres" {
223+
source = "terraform-alicloud-modules/rds-postgres/alicloud"
224+
providers = {
225+
alicloud = alicloud.hz
226+
}
227+
engine_version = "10.0"
228+
instance_storage = 20
229+
instance_charge_type = "Postpaid"
230+
vswitch_id = "vsw-bp1tili2u5kxxxxxx"
231+
instance_name = "PostgreSQLInstance"
232+
instance_type = "rds.pg.s1.small"
233+
}
234+
```
170235

236+
and then run `terraform init` and `terraform apply` to make the defined provider effect to the existing module state.
237+
More details see [How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
171238

172239
Submit Issues
173240
-------------

main.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +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/rds-postgres"
7-
}
8-
91
locals {
102
engine = "PostgreSQL"
113
this_instance_id = var.existing_instance_id != "" ? var.existing_instance_id : concat(alicloud_db_instance.this.*.id, [""])[0]

modules/database/main.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +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/rds-postgres"
7-
}
8-
91
resource "alicloud_db_database" "this" {
102
count = var.create_database ? length(var.databases) : 0
113
instance_id = var.db_instance_id

modules/database/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 "region" {
5-
description = "The region used to launch this module resources."
5+
description = "(Deprecated from version 1.1.0)The region used to launch this module resources."
66
type = string
77
default = ""
88
}
99

1010
variable "profile" {
11-
description = "The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
11+
description = "(Deprecated from version 1.1.0)The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
1212
type = string
1313
default = ""
1414
}
1515

1616
variable "shared_credentials_file" {
17-
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."
17+
description = "(Deprecated from version 1.1.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."
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.1.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
}

modules/postgre_sql-10-basic/main.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
2-
provider "alicloud" {
3-
profile = var.profile != "" ? var.profile : null
4-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
5-
region = var.region != "" ? var.region : null
6-
skip_region_validation = var.skip_region_validation
7-
configuration_source = "terraform-alicloud-modules/rds-postgres"
8-
}
91
locals {
102
engine = "PostgreSQL"
113
engine_version = "10.0"

modules/postgre_sql-10-basic/variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
#################
44

55
variable "region" {
6-
description = "The region used to launch this module resources."
6+
description = "(Deprecated from version 1.1.0)The region used to launch this module resources."
77
type = string
88
default = ""
99
}
1010

1111
variable "profile" {
12-
description = "The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
12+
description = "(Deprecated from version 1.1.0)The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
1313
type = string
1414
default = ""
1515
}
1616

1717
variable "shared_credentials_file" {
18-
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."
18+
description = "(Deprecated from version 1.1.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."
1919
type = string
2020
default = ""
2121
}
2222

2323
variable "skip_region_validation" {
24-
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)."
24+
description = "(Deprecated from version 1.1.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)."
2525
type = bool
2626
default = false
2727
}

modules/postgre_sql-10-high-availability/main.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
2-
provider "alicloud" {
3-
profile = var.profile != "" ? var.profile : null
4-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
5-
region = var.region != "" ? var.region : null
6-
skip_region_validation = var.skip_region_validation
7-
configuration_source = "terraform-alicloud-modules/rds-postgres"
8-
}
91
locals {
102
engine = "PostgreSQL"
113
engine_version = "10.0"

modules/postgre_sql-10-high-availability/variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
#################
44

55
variable "region" {
6-
description = "The region used to launch this module resources."
6+
description = "(Deprecated from version 1.1.0)The region used to launch this module resources."
77
type = string
88
default = ""
99
}
1010

1111
variable "profile" {
12-
description = "The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
12+
description = "(Deprecated from version 1.1.0)The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
1313
type = string
1414
default = ""
1515
}
1616

1717
variable "shared_credentials_file" {
18-
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."
18+
description = "(Deprecated from version 1.1.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."
1919
type = string
2020
default = ""
2121
}
2222

2323
variable "skip_region_validation" {
24-
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)."
24+
description = "(Deprecated from version 1.1.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)."
2525
type = bool
2626
default = false
2727
}

modules/postgre_sql-11-basic/main.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
2-
provider "alicloud" {
3-
profile = var.profile != "" ? var.profile : null
4-
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
5-
region = var.region != "" ? var.region : null
6-
skip_region_validation = var.skip_region_validation
7-
configuration_source = "terraform-alicloud-modules/rds-postgres"
8-
}
91
locals {
102
engine = "PostgreSQL"
113
engine_version = "11.0"

0 commit comments

Comments
 (0)