diff --git a/internal/schema/backends/backends.go b/internal/schema/backends/backends.go index 719ecf2d..87ea95b6 100644 --- a/internal/schema/backends/backends.go +++ b/internal/schema/backends/backends.go @@ -24,6 +24,7 @@ var ( v0_14_0 = version.Must(version.NewVersion("0.14.0")) v0_15_0 = version.Must(version.NewVersion("0.15.0")) v1_3_0 = version.Must(version.NewVersion("1.3.0")) + v1_4_0 = version.Must(version.NewVersion("1.4.0")) ) func BackendTypesAsOneOfConstraint(tfVersion *version.Version) schema.OneOf { diff --git a/internal/schema/backends/cos.go b/internal/schema/backends/cos.go index 8a25fd1e..f567b92b 100644 --- a/internal/schema/backends/cos.go +++ b/internal/schema/backends/cos.go @@ -62,6 +62,61 @@ func cosBackend(v *version.Version) *schema.BodySchema { Description: lang.Markdown("Object ACL to be applied to the state file"), }, }, + Blocks: make(map[string]*schema.BlockSchema, 0), + } + + if v.GreaterThanOrEqual(v1_3_0) { + // See https://github.com/hashicorp/terraform/pull/31425/files + bodySchema.Attributes["accelerate"] = &schema.AttributeSchema{ + Constraint: schema.LiteralType{Type: cty.Bool}, + IsOptional: true, + Description: lang.Markdown("Whether to enable global Acceleration"), + } + } + + if v.GreaterThanOrEqual(v1_4_0) { + // See https://github.com/hashicorp/terraform/pull/32631/files + bodySchema.Attributes["secret_id"].IsRequired = false + bodySchema.Attributes["secret_id"].IsOptional = true + bodySchema.Attributes["secret_key"].IsRequired = false + bodySchema.Attributes["secret_key"].IsOptional = true + + bodySchema.Attributes["security_token"] = &schema.AttributeSchema{ + Constraint: schema.LiteralType{Type: cty.String}, + IsOptional: true, + 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)."), + IsSensitive: true, + } + + bodySchema.Blocks["assume_role"] = &schema.BlockSchema{ + Type: schema.BlockTypeSet, + MaxItems: 1, + Description: lang.Markdown("The `assume_role` block. If provided, terraform will attempt to assume this role using the supplied credentials."), + Body: &schema.BodySchema{ + Attributes: map[string]*schema.AttributeSchema{ + "role_arn": { + Constraint: schema.LiteralType{Type: cty.String}, + IsRequired: true, + Description: lang.Markdown("The ARN of the role to assume. It can be sourced from the `TENCENTCLOUD_ASSUME_ROLE_ARN`."), + }, + "session_name": { + Constraint: schema.LiteralType{Type: cty.String}, + IsRequired: true, + Description: lang.Markdown("The session name to use when making the AssumeRole call. It can be sourced from the `TENCENTCLOUD_ASSUME_ROLE_SESSION_NAME`."), + }, + "session_duration": { + Constraint: schema.LiteralType{Type: cty.Number}, + IsRequired: true, + 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`."), + }, + "policy": { + Constraint: schema.LiteralType{Type: cty.String}, + IsOptional: true, + 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)."), + }, + }, + }, + } } return bodySchema diff --git a/schema/core_schema_test.go b/schema/core_schema_test.go index cb3d948d..86e1be57 100644 --- a/schema/core_schema_test.go +++ b/schema/core_schema_test.go @@ -122,7 +122,7 @@ func TestCoreModuleSchemaForConstraint(t *testing.T) { }, { version.Constraints{}, - mod_v1_2.ModuleSchema(version.Must(version.NewVersion("1.3.0"))), + mod_v1_2.ModuleSchema(version.Must(version.NewVersion("1.4.0"))), nil, }, {