@@ -23,11 +23,20 @@ func ResourceTencentCloudVpcIpv6CidrBlock() *schema.Resource {
23
23
},
24
24
Schema : map [string ]* schema.Schema {
25
25
"vpc_id" : {
26
- Required : true ,
27
26
Type : schema .TypeString ,
27
+ Required : true ,
28
28
ForceNew : true ,
29
29
Description : "`VPC` instance `ID`, in the form of `vpc-f49l6u0z`." ,
30
30
},
31
+
32
+ "address_type" : {
33
+ Type : schema .TypeString ,
34
+ Optional : true ,
35
+ Computed : true ,
36
+ ForceNew : true ,
37
+ Description : "Apply for the type of IPv6 Cidr, GUA (Global Unicast Address), ULA (Unique Local Address)." ,
38
+ },
39
+
31
40
"ipv6_cidr_block" : {
32
41
Type : schema .TypeString ,
33
42
Computed : true ,
@@ -41,26 +50,32 @@ func resourceTencentCloudVpcIpv6CidrBlockCreate(d *schema.ResourceData, meta int
41
50
defer tccommon .LogElapsed ("resource.tencentcloud_vpc_ipv6_cidr_block.create" )()
42
51
defer tccommon .InconsistentCheck (d , meta )()
43
52
44
- logId := tccommon .GetLogId (tccommon .ContextNil )
45
-
46
53
var (
54
+ logId = tccommon .GetLogId (tccommon .ContextNil )
47
55
request = vpc .NewAssignIpv6CidrBlockRequest ()
48
56
vpcId string
49
57
)
58
+
50
59
if v , ok := d .GetOk ("vpc_id" ); ok {
51
60
vpcId = v .(string )
52
61
request .VpcId = helper .String (vpcId )
53
62
}
54
63
64
+ if v , ok := d .GetOk ("address_type" ); ok {
65
+ request .AddressType = helper .String (v .(string ))
66
+ }
67
+
55
68
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
56
69
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseVpcClient ().AssignIpv6CidrBlock (request )
57
70
if e != nil {
58
71
return tccommon .RetryError (e )
59
72
} else {
60
73
log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
61
74
}
75
+
62
76
return nil
63
77
})
78
+
64
79
if err != nil {
65
80
log .Printf ("[CRITAL]%s create vpc ipv6CidrBlock failed, reason:%+v" , logId , err )
66
81
return err
@@ -75,13 +90,12 @@ func resourceTencentCloudVpcIpv6CidrBlockRead(d *schema.ResourceData, meta inter
75
90
defer tccommon .LogElapsed ("resource.tencentcloud_vpc_ipv6_cidr_block.read" )()
76
91
defer tccommon .InconsistentCheck (d , meta )()
77
92
78
- logId := tccommon .GetLogId (tccommon .ContextNil )
79
-
80
- ctx := context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
81
-
82
- service := VpcService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
83
-
84
- vpcId := d .Id ()
93
+ var (
94
+ logId = tccommon .GetLogId (tccommon .ContextNil )
95
+ ctx = context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
96
+ service = VpcService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
97
+ vpcId = d .Id ()
98
+ )
85
99
86
100
instance , err := service .DescribeVpcById (ctx , vpcId )
87
101
if err != nil {
@@ -98,6 +112,10 @@ func resourceTencentCloudVpcIpv6CidrBlockRead(d *schema.ResourceData, meta inter
98
112
_ = d .Set ("vpc_id" , instance .VpcId )
99
113
}
100
114
115
+ if instance .Ipv6CidrBlockSet != nil && len (instance .Ipv6CidrBlockSet ) != 0 {
116
+ _ = d .Set ("address_type" , instance .Ipv6CidrBlockSet [0 ].AddressType )
117
+ }
118
+
101
119
if instance .Ipv6CidrBlock != nil {
102
120
_ = d .Set ("ipv6_cidr_block" , instance .Ipv6CidrBlock )
103
121
}
@@ -109,11 +127,12 @@ func resourceTencentCloudVpcIpv6CidrBlockDelete(d *schema.ResourceData, meta int
109
127
defer tccommon .LogElapsed ("resource.tencentcloud_vpc_ipv6_cidr_block.delete" )()
110
128
defer tccommon .InconsistentCheck (d , meta )()
111
129
112
- logId := tccommon .GetLogId (tccommon .ContextNil )
113
- ctx := context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
114
-
115
- service := VpcService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
116
- vpcId := d .Id ()
130
+ var (
131
+ logId = tccommon .GetLogId (tccommon .ContextNil )
132
+ ctx = context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
133
+ service = VpcService {client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn ()}
134
+ vpcId = d .Id ()
135
+ )
117
136
118
137
if err := service .DeleteVpcIpv6CidrBlockById (ctx , vpcId ); err != nil {
119
138
return err
0 commit comments