Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/alicloud_vpc: Adds new attribute classic_link_enabled, create_time, ipv6_cidr_blocks, ipv6_isp; resource/alicloud_vswitch: Adds new attributes create_time, resource_group_id, route_table_id. #6119

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

ChenHanZhang
Copy link
Collaborator

No description provided.

@ChenHanZhang ChenHanZhang force-pushed the AutoGenVpcVpc branch 5 times, most recently from a0b0ef4 to 0f5e242 Compare May 16, 2023 09:22
@ChenHanZhang ChenHanZhang force-pushed the AutoGenVpcVpc branch 3 times, most recently from 448936d to 800ea00 Compare May 30, 2023 06:01

-> **NOTE:** Terraform will auto build a router and a route table while it uses `alicloud_vpc` to build a vpc resource.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个信息不能丢失,已经维护到Spec上的资源英文描述中

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,已经维护到spec上

CheckDestroy: rac.checkResourceDestroy(),
Steps: []resource.TestStep{
{
Config: testAccConfig(map[string]interface{}{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当存在资源名称的属性时,应该作为测试第一步属性值

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* `ipv6_cidr_blocks` - The IPv6 CIDR block information of the VPC.
* `ipv6_cidr_block` - The IPv6 CIDR block of the VPC.
* `ipv6_isp` - Valid values: **BGP** (default): Alibaba Cloud BGP IPv6.
-*ChinaMobile**: China Mobile (single line).
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要多两格缩进

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

request["Ipv6CidrBlock"] = d.Get("ipv6_cidr_block")
}

if v, ok := d.GetOkExists("enable_ipv6"); ok {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

操作私有属性,不用判定HasChange,设置有值的时候随着api的调用传入即可

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@ChenHanZhang ChenHanZhang force-pushed the AutoGenVpcVpc branch 5 times, most recently from 5b0c77f to 42b8366 Compare May 31, 2023 06:02
@ChenHanZhang ChenHanZhang changed the title resource/alicloud_vpc: Adds new attribute classic_link_enabled. resource/alicloud_vpc: Adds new attribute classic_link_enabled, create_time, dhcp_options_set_id, ipv6_cidr_blocks, ipv6_isp, vswitch_ids, vpc_id; resource/alicloud_vswitch: Adds new attributes create_time, network_acl_id, resource_group_id, route_table_id, vswitch_id. May 31, 2023
},
"dry_run": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dry_run 不应该是ForceNew的

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Type: schema.TypeString,
Computed: true,
},
"resource_group_id": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

资源组需要支持更新

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已确认VSwitch暂时不支持资源组,去除定义


For information about Vpc Vpc and how to use it, see [What is Vpc](https://www.alibabacloud.com/help/en/virtual-private-cloud/latest/what-is-a-vpc).

-> **NOTE:** Available in v1.206.0+.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个信息不正确,去掉

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- **ChinaUnicom**: China Unicom (single line).
- **ChinaTelecom**: China Telecom (single line).
> If a single-line bandwidth whitelist is enabled, this field can be set to **ChinaTelecom** (China Telecom), **ChinaUnicom** (China Unicom), or **ChinaMobile** (China Mobile).
* `resource_group_id` - (Optional, Computed) The ID of the resource group to which the VPC belongs.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

资源组的可用版本信息

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
```

## Module Support

You can use to the existing [vpc module](https://registry.terraform.io/modules/alibaba/vpc/alicloud)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个信息还是要维护起来

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

## Argument Reference

The following arguments are supported:

* `availability_zone` - (Optional, ForceNew, Deprecated from v1.119.0+) Field `availability_zone` has been deprecated from provider version 1.119.0. New field `zone_id` instead.
* `zone_id` - (Optional, ForceNew, Available in 1.119.0+) The AZ for the switch. **Note:** Required for a VPC switch.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看下生成器为什么丢失了zone_id

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- **true**: enables IPv6.
- **false** (default): IPv6 is not enabled.
* `ipv6_cidr_block_mask` - (Optional) The IPv6 CIDR block of the VSwitch.
* `tags` - (Optional, Map) The tags of VSwitch.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags、vswitch_name、enable_ipv6、ipv6_cidr_block_mask 的版本信息丢失了

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


## Example Usage

Basic Usage

```terraform
resource "alicloud_vpc" "vpc" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里以前的示例更加丰富,需要考虑生成器如何生成指定的多个测试用例,目前仅生成一个。这里先将以前的用例补充回来。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ValidateFunc: validateCIDRNetworkAddress,
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个默认值应该去不掉,你试试通过API的方式,不传这个参数会有问题么

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

试了可以,系统默认值就是 172.16.0.0/12

ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"vswitch_ids": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个vswitch_ids没必要透出

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,后续滤除除status和create_time之外其它的所有只读属性,除存量已经透出的字段,后续新增的只读属性在Resource上不再透出

"route_table_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

route_table_id这个属性没有在 CUD 中出现啊

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

route_table_id是标准的属性名,同以前的router_table_id

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个属性是需要保留的

Elem: &schema.Schema{Type: schema.TypeString},
},
"vpc_id": {
Type: schema.TypeString,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经有 id 了,不需要 vpc_id 了

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Check: resource.ComposeTestCheckFunc(
testAccCheck(map[string]string{
"cidr_block": "172.16.0.0/12",
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥 cidr_block, vpc_name, description 反复修改了很多次

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

生成逻辑的缺陷,目前资源测试用例录入n步后,生成的Terraform测试步骤会处理为:

  1. 资源用例第1步中如果存在必填值,则将用例中第1步只取必填保留,剩下的其它非必填的m个可改属性,会拆分为m步;
  2. 资源用例第2到n步中的所有可改属性,按单个属性更新的方式拆分为 (n-1)*m 步。
    所有录入的时候,第一步全填值并且存在较多的可改属性,第二、三步中的可改属性重复,那么生成的时候就反复修改。
    这里可以进一步优化一下生成逻辑。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"status": {
Type: schema.TypeString,
Computed: true,
},
"tags": tagsSchema(),
"vswitch_id": {
Type: schema.TypeString,
Computed: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个也一样

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ResourceName: resourceId,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"enable_ipv6", "ipv6_cidr_block_mask"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ipv6_cidr_block_mask 不应该被 ignore

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ipv6_cidr_block_mask 实际在spec上的定义就是一个操作私有属性,目前Spec上一个出参仅能对应一个属性,api上的这个对应参数映射到了另一个属性(Ipv6Block)上了。所以这个属性是个操作私有属性,因此生成的时候这里被ignore了。
这里考虑对spec进行扩展,支持在资源属性上直接定义JSONNata,这样就可以当成普通属性正常取值。

@ChenHanZhang ChenHanZhang changed the title resource/alicloud_vpc: Adds new attribute classic_link_enabled, create_time, dhcp_options_set_id, ipv6_cidr_blocks, ipv6_isp, vswitch_ids, vpc_id; resource/alicloud_vswitch: Adds new attributes create_time, network_acl_id, resource_group_id, route_table_id, vswitch_id. resource/alicloud_vpc: Adds new attribute classic_link_enabled, create_time, ipv6_cidr_blocks, ipv6_isp; resource/alicloud_vswitch: Adds new attributes create_time, resource_group_id, route_table_id. Jun 1, 2023
})
}

var AlicloudVpcVpcMap3113 = map[string]string{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

computed 的check set 下吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

…e_time, dhcp_options_set_id, ipv6_cidr_blocks, ipv6_isp, vswitch_ids, vpc_id; resource/alicloud_vswitch: Adds new attributes create_time, network_acl_id, route_table_id, vswitch_id.
@xiaozhu36 xiaozhu36 merged commit ad046cb into aliyun:master Jun 2, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants