Skip to content

Commit 23ee279

Browse files
王超xiaozhu36
authored andcommitted
Removes the provider setting and improves the Readme
1 parent 6be1643 commit 23ee279

File tree

3 files changed

+87
-13
lines changed

3 files changed

+87
-13
lines changed

README-CN.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ terraform-alicloud-redis
1414

1515
## Terraform 版本
1616

17-
本模板要求使用版本 Terraform 0.12 和阿里云 Provider 1.56.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.56.0
1821

1922
## 用法
2023

@@ -152,8 +155,45 @@ module "redis" {
152155
更多模板详见 [Modules](https://github.com/terraform-alicloud-modules/terraform-alicloud-redis/tree/master/modules).
153156

154157
## 注意事项
158+
本Module从版本v1.9.0开始已经移除掉如下的 provider 的显示设置:
159+
```hcl
160+
provider "alicloud" {
161+
profile = var.profile != "" ? var.profile : null
162+
region = var.region != "" ? var.region : null
163+
skip_region_validation = var.skip_region_validation
164+
}
165+
```
166+
167+
如果你依然想在Module中使用这个 provider 配置,你可以在调用Module的时候,指定一个特定的版本,比如 1.8.0:
168+
169+
```hcl
170+
module "redis" {
171+
source = "alibaba/redis/alicloud"
172+
version = "1.8.0"
173+
region = "cn-hangzhou"
174+
profile = "Your-Profile-Name"
175+
create = true
176+
vpc_name = "my-env-redis"
177+
// ...
178+
}
179+
```
180+
如果你想对正在使用中的Module升级到 1.9.0 或者更高的版本,那么你可以在模板中显示定义一个系统过Region的provider:
181+
```hcl
182+
provider "alicloud" {
183+
region = "cn-hangzhou"
184+
profile = "Your-Profile-Name"
185+
}
186+
module "redis" {
187+
source = "alibaba/redis/alicloud"
188+
create = true
189+
vpc_name = "my-env-redis"
190+
// ...
191+
}
192+
```
193+
194+
定义完provider之后,运行命令 `terraform init``terraform apply` 来让这个provider生效即可。
155195

156-
* 本 Module 使用的 AccessKey 和 SecretKey 可以直接从 `profile``shared_credentials_file` 中获取。如果未设置,可通过下载安装 [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) 后进行配置。
196+
更多provider的使用细节,请移步[How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
157197

158198
作者
159199
-------

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ These types of resources are supported:
1515

1616
## Terraform versions
1717

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

2023
Usage
2124
-----
@@ -156,10 +159,49 @@ This module provides rich sub-modules to support different Redis version and usa
156159
See [more modules](https://github.com/terraform-alicloud-modules/terraform-alicloud-redis/tree/master/modules).
157160

158161
## Notes
162+
From the version v1.9.0, the module has removed the following `provider` setting:
159163

160-
* This module using AccessKey and SecretKey are from `profile` and `shared_credentials_file`.
161-
If you have not set them yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it.
164+
```hcl
165+
provider "alicloud" {
166+
profile = var.profile != "" ? var.profile : null
167+
region = var.region != "" ? var.region : null
168+
skip_region_validation = var.skip_region_validation
169+
}
170+
```
171+
172+
If you still want to use the `provider` setting to apply this module, you can specify a supported version, like 1.8.0:
173+
174+
```hcl
175+
module "vpc" {
176+
source = "alibaba/redis/alicloud"
177+
version = "1.8.0"
178+
region = "cn-hangzhou"
179+
profile = "Your-Profile-Name"
180+
181+
create = true
182+
vpc_name = "my-env-redis"
183+
// ...
184+
}
185+
```
186+
187+
If you want to upgrade the module to 1.9.0 or higher in-place, you can define a provider which same region with
188+
previous region:
189+
190+
```hcl
191+
provider "alicloud" {
192+
region = "cn-hangzhou"
193+
profile = "Your-Profile-Name"
194+
}
195+
module "redis" {
196+
source = "alibaba/redis/alicloud"
197+
create = true
198+
vpc_name = "my-env-redis"
199+
// ...
200+
}
201+
```
162202

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

164206
Authors
165207
---------

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/redis"
7-
}
8-
91
locals {
102
this_instance_id = var.existing_instance_id != "" ? var.existing_instance_id : concat(alicloud_kvstore_instance.this.*.id, [""])[0]
113
create_more_resources = var.existing_instance_id != "" || var.create_instance ? true : false

0 commit comments

Comments
 (0)