Skip to content

Commit 3d07383

Browse files
authored
backends/cos: Add 1.3 and 1.4 attributes & blocks (#217)
* backends/cos: Add v1.3 attribute accelerate * backends/cos: Add v1.4 attributes & blocks
1 parent 7147896 commit 3d07383

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

internal/schema/backends/backends.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var (
2424
v0_14_0 = version.Must(version.NewVersion("0.14.0"))
2525
v0_15_0 = version.Must(version.NewVersion("0.15.0"))
2626
v1_3_0 = version.Must(version.NewVersion("1.3.0"))
27+
v1_4_0 = version.Must(version.NewVersion("1.4.0"))
2728
)
2829

2930
func BackendTypesAsOneOfConstraint(tfVersion *version.Version) schema.OneOf {

internal/schema/backends/cos.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,61 @@ func cosBackend(v *version.Version) *schema.BodySchema {
6262
Description: lang.Markdown("Object ACL to be applied to the state file"),
6363
},
6464
},
65+
Blocks: make(map[string]*schema.BlockSchema, 0),
66+
}
67+
68+
if v.GreaterThanOrEqual(v1_3_0) {
69+
// See https://github.com/hashicorp/terraform/pull/31425/files
70+
bodySchema.Attributes["accelerate"] = &schema.AttributeSchema{
71+
Constraint: schema.LiteralType{Type: cty.Bool},
72+
IsOptional: true,
73+
Description: lang.Markdown("Whether to enable global Acceleration"),
74+
}
75+
}
76+
77+
if v.GreaterThanOrEqual(v1_4_0) {
78+
// See https://github.com/hashicorp/terraform/pull/32631/files
79+
bodySchema.Attributes["secret_id"].IsRequired = false
80+
bodySchema.Attributes["secret_id"].IsOptional = true
81+
bodySchema.Attributes["secret_key"].IsRequired = false
82+
bodySchema.Attributes["secret_key"].IsOptional = true
83+
84+
bodySchema.Attributes["security_token"] = &schema.AttributeSchema{
85+
Constraint: schema.LiteralType{Type: cty.String},
86+
IsOptional: true,
87+
Description: lang.Markdown("TencentCloud Security Token of temporary access credentials. It can be sourced from the `TENCENTCLOUD_SECURITY_TOKEN` environment variable. Notice: for supported products, please refer to: [temporary key supported products](https://intl.cloud.tencent.com/document/product/598/10588)."),
88+
IsSensitive: true,
89+
}
90+
91+
bodySchema.Blocks["assume_role"] = &schema.BlockSchema{
92+
Type: schema.BlockTypeSet,
93+
MaxItems: 1,
94+
Description: lang.Markdown("The `assume_role` block. If provided, terraform will attempt to assume this role using the supplied credentials."),
95+
Body: &schema.BodySchema{
96+
Attributes: map[string]*schema.AttributeSchema{
97+
"role_arn": {
98+
Constraint: schema.LiteralType{Type: cty.String},
99+
IsRequired: true,
100+
Description: lang.Markdown("The ARN of the role to assume. It can be sourced from the `TENCENTCLOUD_ASSUME_ROLE_ARN`."),
101+
},
102+
"session_name": {
103+
Constraint: schema.LiteralType{Type: cty.String},
104+
IsRequired: true,
105+
Description: lang.Markdown("The session name to use when making the AssumeRole call. It can be sourced from the `TENCENTCLOUD_ASSUME_ROLE_SESSION_NAME`."),
106+
},
107+
"session_duration": {
108+
Constraint: schema.LiteralType{Type: cty.Number},
109+
IsRequired: true,
110+
Description: lang.Markdown("The duration of the session when making the AssumeRole call. Its value ranges from 0 to 43200(seconds), and default is 7200 seconds. It can be sourced from the `TENCENTCLOUD_ASSUME_ROLE_SESSION_DURATION`."),
111+
},
112+
"policy": {
113+
Constraint: schema.LiteralType{Type: cty.String},
114+
IsOptional: true,
115+
Description: lang.Markdown("A more restrictive policy when making the AssumeRole call. Its content must not contains `principal` elements. Notice: more syntax references, please refer to: [policies syntax logic](https://intl.cloud.tencent.com/document/product/598/10603)."),
116+
},
117+
},
118+
},
119+
}
65120
}
66121

67122
return bodySchema

schema/core_schema_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func TestCoreModuleSchemaForConstraint(t *testing.T) {
122122
},
123123
{
124124
version.Constraints{},
125-
mod_v1_2.ModuleSchema(version.Must(version.NewVersion("1.3.0"))),
125+
mod_v1_2.ModuleSchema(version.Must(version.NewVersion("1.4.0"))),
126126
nil,
127127
},
128128
{

0 commit comments

Comments
 (0)