From 243c2ee310078b9b927fbe745c433c45a2faf0a6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 23 Jun 2023 08:37:09 -0400 Subject: [PATCH 01/20] Start pprof HTTP server. --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index b40c75d2eb2e..468a48297558 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,8 @@ import ( "context" "flag" "log" + "net/http" + _ "net/http/pprof" "github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server" "github.com/hashicorp/terraform-provider-aws/internal/provider" @@ -19,6 +21,10 @@ func main() { log.Fatal(err) } + go func() { + http.ListenAndServe("localhost:8080", nil) + }() + var serveOpts []tf5server.ServeOpt if *debugFlag { From 2169620bf67fa86e05487a9b21cb0d1e576ee819 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 23 Jun 2023 13:54:07 -0400 Subject: [PATCH 02/20] Run 'go mod edit -replace github.com/hashicorp/terraform-plugin-sdk/v2=github.com/hashicorp/terraform-plugin-sdk/v2@b742d27834e16ba639554755346b43bb5d5a2f95 && go mod tidy'. --- go.mod | 18 ++++++++++-------- go.sum | 36 ++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 443a7daf3710..421e1b0644f9 100644 --- a/go.mod +++ b/go.mod @@ -67,7 +67,7 @@ require ( github.com/hashicorp/terraform-plugin-framework v1.3.1 github.com/hashicorp/terraform-plugin-framework-timeouts v0.3.1 github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 - github.com/hashicorp/terraform-plugin-go v0.15.0 + github.com/hashicorp/terraform-plugin-go v0.16.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-mux v0.10.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 @@ -113,18 +113,18 @@ require ( github.com/cloudflare/circl v1.3.3 // indirect github.com/evanphx/json-patch v0.5.2 // indirect github.com/fatih/color v1.14.1 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-plugin v1.4.9 // indirect + github.com/hashicorp/go-plugin v1.4.10 // indirect github.com/hashicorp/hc-install v0.5.2 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/terraform-exec v0.18.1 // indirect github.com/hashicorp/terraform-json v0.17.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.0 // indirect - github.com/hashicorp/terraform-svchost v0.1.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.1 // indirect + github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.13 // indirect @@ -147,14 +147,16 @@ require ( go.opentelemetry.io/otel v1.15.1 // indirect go.opentelemetry.io/otel/trace v1.15.1 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.11.0 // indirect golang.org/x/sys v0.9.0 // indirect golang.org/x/text v0.10.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230202175211-008b39050e57 // indirect - google.golang.org/grpc v1.54.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.56.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/hashicorp/aws-sdk-go-base/v2 => github.com/hashicorp/aws-sdk-go-base/v2 v2.0.0-beta.29.0.20230622181216-1c3bdec608c2 + +replace github.com/hashicorp/terraform-plugin-sdk/v2 => github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.2-0.20230623145513-b742d27834e1 diff --git a/go.sum b/go.sum index 5fed1785de0c..46b1ca6fb649 100644 --- a/go.sum +++ b/go.sum @@ -171,8 +171,8 @@ github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -205,8 +205,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.9 h1:ESiK220/qE0aGxWdzKIvRH69iLiuN/PjoLTm69RoWtU= -github.com/hashicorp/go-plugin v1.4.9/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= +github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -228,20 +228,20 @@ github.com/hashicorp/terraform-plugin-framework-timeouts v0.3.1 h1:5GhozvHUsrqxq github.com/hashicorp/terraform-plugin-framework-timeouts v0.3.1/go.mod h1:ThtYDU8p6sJ9+SI+TYxXrw28vXxgBwYOpoPv1EojSJI= github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8esP6OcvocVymw52lY0HyQ5OxB7VNl7k4bS0= github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE= -github.com/hashicorp/terraform-plugin-go v0.15.0 h1:1BJNSUFs09DS8h/XNyJNJaeusQuWc/T9V99ylU9Zwp0= -github.com/hashicorp/terraform-plugin-go v0.15.0/go.mod h1:tk9E3/Zx4RlF/9FdGAhwxHExqIHHldqiQGt20G6g+nQ= +github.com/hashicorp/terraform-plugin-go v0.16.0 h1:DSOQ0rz5FUiVO4NUzMs8ln9gsPgHMTsfns7Nk+6gPuE= +github.com/hashicorp/terraform-plugin-go v0.16.0/go.mod h1:4sn8bFuDbt+2+Yztt35IbOrvZc0zyEi87gJzsTgCES8= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-plugin-mux v0.10.0 h1:VejY1BffxGy2iYOaa8DDHavY4k9jbvAE8F3lhruspKY= github.com/hashicorp/terraform-plugin-mux v0.10.0/go.mod h1:9sdnpmY20xIsl4ItsfODZYE+MgpSy/osXpSf+RwaZCY= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 h1:G9WAfb8LHeCxu7Ae8nc1agZlQOSCUWsb610iAogBhCs= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1/go.mod h1:xcOSYlRVdPLmDUoqPhO9fiO/YCN/l6MGYeTzGt5jgkQ= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.2-0.20230623145513-b742d27834e1 h1:j+muaVcqGivW87pGoD9752xSN7WTkucbIySpKbNYy4s= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.2-0.20230623145513-b742d27834e1/go.mod h1:wJt70/1GeZ4WXQ5Gpmxai6PCOsUXAYjhJKHGPhBfRrI= github.com/hashicorp/terraform-plugin-testing v1.3.0 h1:4Pn8fSspPCRUc5zRGPNZYc00VhQmQPEH6y6Pv4e/42M= github.com/hashicorp/terraform-plugin-testing v1.3.0/go.mod h1:mGOfGFTVIhP9buGPZyDQhmZFIO/Ig8E0Fo694UACr64= -github.com/hashicorp/terraform-registry-address v0.2.0 h1:92LUg03NhfgZv44zpNTLBGIbiyTokQCDcdH5BhVHT3s= -github.com/hashicorp/terraform-registry-address v0.2.0/go.mod h1:478wuzJPzdmqT6OGbB/iH82EDcI8VFM4yujknh/1nIs= -github.com/hashicorp/terraform-svchost v0.1.0 h1:0+RcgZdZYNd81Vw7tu62g9JiLLvbOigp7QtyNh6CjXk= -github.com/hashicorp/terraform-svchost v0.1.0/go.mod h1:ut8JaH0vumgdCfJaihdcZULqkAwHdQNwNH7taIDdsZM= +github.com/hashicorp/terraform-registry-address v0.2.1 h1:QuTf6oJ1+WSflJw6WYOHhLgwUiQ0FrROpHPYFtwTYWM= +github.com/hashicorp/terraform-registry-address v0.2.1/go.mod h1:BSE9fIFzp0qWsJUUyGquo4ldV9k2n+psif6NYkBRS3Y= +github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= +github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -362,8 +362,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -405,10 +405,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20230202175211-008b39050e57 h1:vArvWooPH749rNHpBGgVl+U9B9dATjiEhJzcWGlovNs= -google.golang.org/genproto v0.0.0-20230202175211-008b39050e57/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/grpc v1.56.0 h1:+y7Bs8rtMd07LeXmL3NxcTLn7mUkbKZqEpPhMNkwJEE= +google.golang.org/grpc v1.56.0/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= From 39fc99f17f1f35f38fd12c121f95bccf3f82daf6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 23 Jun 2023 14:00:12 -0400 Subject: [PATCH 03/20] wafv2: Implement 'SchemaFunc()'. --- internal/service/wafv2/ip_set.go | 118 +++++----- internal/service/wafv2/ip_set_data_source.go | 56 ++--- internal/service/wafv2/regex_pattern_set.go | 86 +++---- .../wafv2/regex_pattern_set_data_source.go | 56 ++--- internal/service/wafv2/rule_group.go | 140 ++++++------ .../service/wafv2/rule_group_data_source.go | 38 +-- internal/service/wafv2/web_acl.go | 194 ++++++++-------- internal/service/wafv2/web_acl_association.go | 28 +-- internal/service/wafv2/web_acl_data_source.go | 38 +-- .../wafv2/web_acl_logging_configuration.go | 216 +++++++++--------- 10 files changed, 495 insertions(+), 475 deletions(-) diff --git a/internal/service/wafv2/ip_set.go b/internal/service/wafv2/ip_set.go index 0e1d707656ce..8c7ae1fd9058 100644 --- a/internal/service/wafv2/ip_set.go +++ b/internal/service/wafv2/ip_set.go @@ -52,69 +52,71 @@ func ResourceIPSet() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "addresses": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 10000, - Elem: &schema.Schema{Type: schema.TypeString}, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - if d.GetRawPlan().GetAttr("addresses").IsWhollyKnown() { - o, n := d.GetChange("addresses") - oldAddresses := o.(*schema.Set).List() - newAddresses := n.(*schema.Set).List() - if len(oldAddresses) == len(newAddresses) { - for _, ov := range oldAddresses { - hasAddress := false - for _, nv := range newAddresses { - if itypes.CIDRBlocksEqual(ov.(string), nv.(string)) { - hasAddress = true - break + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "addresses": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 10000, + Elem: &schema.Schema{Type: schema.TypeString}, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if d.GetRawPlan().GetAttr("addresses").IsWhollyKnown() { + o, n := d.GetChange("addresses") + oldAddresses := o.(*schema.Set).List() + newAddresses := n.(*schema.Set).List() + if len(oldAddresses) == len(newAddresses) { + for _, ov := range oldAddresses { + hasAddress := false + for _, nv := range newAddresses { + if itypes.CIDRBlocksEqual(ov.(string), nv.(string)) { + hasAddress = true + break + } + } + if !hasAddress { + return false } } - if !hasAddress { - return false - } + return true } - return true } - } - return false + return false + }, }, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "ip_address_version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.IPAddressVersion_Values(), false), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "ip_address_version": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.IPAddressVersion_Values(), false), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/ip_set_data_source.go b/internal/service/wafv2/ip_set_data_source.go index bb0642590111..6d51279af4c9 100644 --- a/internal/service/wafv2/ip_set_data_source.go +++ b/internal/service/wafv2/ip_set_data_source.go @@ -18,33 +18,35 @@ func DataSourceIPSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceIPSetRead, - Schema: map[string]*schema.Schema{ - "addresses": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "ip_address_version": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "addresses": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "ip_address_version": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/regex_pattern_set.go b/internal/service/wafv2/regex_pattern_set.go index 0569eebd036e..f3ed8494a070 100644 --- a/internal/service/wafv2/regex_pattern_set.go +++ b/internal/service/wafv2/regex_pattern_set.go @@ -50,51 +50,53 @@ func ResourceRegexPatternSet() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "regular_expression": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 10, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "regex_string": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 200), - validation.StringIsValidRegExp, - ), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "regular_expression": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "regex_string": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 200), + validation.StringIsValidRegExp, + ), + }, }, }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/regex_pattern_set_data_source.go b/internal/service/wafv2/regex_pattern_set_data_source.go index 14f9d8f055cc..f4e5534c83e8 100644 --- a/internal/service/wafv2/regex_pattern_set_data_source.go +++ b/internal/service/wafv2/regex_pattern_set_data_source.go @@ -17,36 +17,38 @@ func DataSourceRegexPatternSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceRegexPatternSetRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "regular_expression": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "regex_string": { - Type: schema.TypeString, - Computed: true, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "regular_expression": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "regex_string": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/rule_group.go b/internal/service/wafv2/rule_group.go index 4e839aeb935f..200060752186 100644 --- a/internal/service/wafv2/rule_group.go +++ b/internal/service/wafv2/rule_group.go @@ -53,80 +53,82 @@ func ResourceRuleGroup() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "capacity": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - ValidateFunc: validation.IntAtLeast(1), - }, - "custom_response_body": customResponseBodySchema(), - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 128), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), - ), - }, - "rule": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - "captcha": captchaConfigSchema(), - "challenge": challengeConfigSchema(), - "count": countConfigSchema(), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "capacity": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "custom_response_body": customResponseBodySchema(), + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 128), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + ), + }, + "rule": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + "captcha": captchaConfigSchema(), + "challenge": challengeConfigSchema(), + "count": countConfigSchema(), + }, }, }, + "captcha_config": outerCaptchaConfigSchema(), + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "priority": { + Type: schema.TypeInt, + Required: true, + }, + "rule_label": ruleLabelsSchema(), + "statement": ruleGroupRootStatementSchema(ruleGroupRootStatementSchemaLevel), + "visibility_config": visibilityConfigSchema(), }, - "captcha_config": outerCaptchaConfigSchema(), - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "priority": { - Type: schema.TypeInt, - Required: true, - }, - "rule_label": ruleLabelsSchema(), - "statement": ruleGroupRootStatementSchema(ruleGroupRootStatementSchemaLevel), - "visibility_config": visibilityConfigSchema(), }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "visibility_config": visibilityConfigSchema(), + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "visibility_config": visibilityConfigSchema(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/rule_group_data_source.go b/internal/service/wafv2/rule_group_data_source.go index 615ef6939e33..70d8d6d16ea0 100644 --- a/internal/service/wafv2/rule_group_data_source.go +++ b/internal/service/wafv2/rule_group_data_source.go @@ -17,24 +17,26 @@ func DataSourceRuleGroup() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceRuleGroupRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index f6d8adb12662..b3106d347a44 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -54,112 +54,114 @@ func ResourceWebACL() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "capacity": { - Type: schema.TypeInt, - Computed: true, - }, - "captcha_config": outerCaptchaConfigSchema(), - "custom_response_body": customResponseBodySchema(), - "default_action": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "capacity": { + Type: schema.TypeInt, + Computed: true, + }, + "captcha_config": outerCaptchaConfigSchema(), + "custom_response_body": customResponseBodySchema(), + "default_action": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + }, }, }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 128), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), - ), - }, - "rule": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - "captcha": captchaConfigSchema(), - "challenge": challengeConfigSchema(), - "count": countConfigSchema(), + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 128), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + ), + }, + "rule": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + "captcha": captchaConfigSchema(), + "challenge": challengeConfigSchema(), + "count": countConfigSchema(), + }, }, }, - }, - "captcha_config": outerCaptchaConfigSchema(), - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "override_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "count": emptySchema(), - "none": emptySchema(), + "captcha_config": outerCaptchaConfigSchema(), + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "override_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "count": emptySchema(), + "none": emptySchema(), + }, }, }, + "priority": { + Type: schema.TypeInt, + Required: true, + }, + "rule_label": ruleLabelsSchema(), + "statement": webACLRootStatementSchema(webACLRootStatementSchemaLevel), + "visibility_config": visibilityConfigSchema(), }, - "priority": { - Type: schema.TypeInt, - Required: true, - }, - "rule_label": ruleLabelsSchema(), - "statement": webACLRootStatementSchema(webACLRootStatementSchemaLevel), - "visibility_config": visibilityConfigSchema(), }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "token_domains": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 253), - validation.StringMatch(regexp.MustCompile(`^[\w\.\-/]+$`), "must contain only alphanumeric, hyphen, dot, underscore and forward-slash characters"), - ), + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), }, - }, - "visibility_config": visibilityConfigSchema(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "token_domains": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 253), + validation.StringMatch(regexp.MustCompile(`^[\w\.\-/]+$`), "must contain only alphanumeric, hyphen, dot, underscore and forward-slash characters"), + ), + }, + }, + "visibility_config": visibilityConfigSchema(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/web_acl_association.go b/internal/service/wafv2/web_acl_association.go index 669a51575526..0b1c51576e9d 100644 --- a/internal/service/wafv2/web_acl_association.go +++ b/internal/service/wafv2/web_acl_association.go @@ -33,19 +33,21 @@ func ResourceWebACLAssociation() *schema.Resource { Create: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "resource_arn": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "web_acl_arn": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - ValidateFunc: verify.ValidARN, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "resource_arn": { + Type: schema.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "web_acl_arn": { + Type: schema.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: verify.ValidARN, + }, + } }, } } diff --git a/internal/service/wafv2/web_acl_data_source.go b/internal/service/wafv2/web_acl_data_source.go index caaf5fbbb03d..18cb2a08d111 100644 --- a/internal/service/wafv2/web_acl_data_source.go +++ b/internal/service/wafv2/web_acl_data_source.go @@ -17,24 +17,26 @@ func DataSourceWebACL() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceWebACLRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/web_acl_logging_configuration.go b/internal/service/wafv2/web_acl_logging_configuration.go index 6d1a25f8d0c3..3e9d64500689 100644 --- a/internal/service/wafv2/web_acl_logging_configuration.go +++ b/internal/service/wafv2/web_acl_logging_configuration.go @@ -34,135 +34,137 @@ func ResourceWebACLLoggingConfiguration() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "log_destination_configs": { - Type: schema.TypeSet, - Required: true, - ForceNew: true, - MinItems: 1, - MaxItems: 100, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidARN, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "log_destination_configs": { + Type: schema.TypeSet, + Required: true, + ForceNew: true, + MinItems: 1, + MaxItems: 100, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: verify.ValidARN, + }, + Description: "AWS Kinesis Firehose Delivery Stream ARNs", }, - Description: "AWS Kinesis Firehose Delivery Stream ARNs", - }, - "logging_filter": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "default_behavior": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), - }, - "filter": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "behavior": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), - }, - "condition": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.ActionValue_Values(), false), + "logging_filter": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "default_behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), + }, + "filter": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), + }, + "condition": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.ActionValue_Values(), false), + }, }, }, }, - }, - "label_name_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "label_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 1024), - validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z_\-:]+$`), "must contain only alphanumeric characters, underscores, hyphens, and colons"), - ), + "label_name_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "label_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 1024), + validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z_\-:]+$`), "must contain only alphanumeric characters, underscores, hyphens, and colons"), + ), + }, }, }, }, }, }, }, - }, - "requirement": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterRequirement_Values(), false), + "requirement": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterRequirement_Values(), false), + }, }, }, }, }, }, }, - }, - "redacted_fields": { - // To allow this argument and its nested fields with Empty Schemas (e.g. "method") - // to be correctly interpreted, this argument must be of type List, - // otherwise, at apply-time a field configured as an empty block - // (e.g. body {}) will result in a nil redacted_fields attribute - Type: schema.TypeList, - Optional: true, - MaxItems: 100, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "method": emptySchema(), - "query_string": emptySchema(), - "single_header": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 40), - // The value is returned in lower case by the API. - // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. - validation.StringMatch(regexp.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), - ), + "redacted_fields": { + // To allow this argument and its nested fields with Empty Schemas (e.g. "method") + // to be correctly interpreted, this argument must be of type List, + // otherwise, at apply-time a field configured as an empty block + // (e.g. body {}) will result in a nil redacted_fields attribute + Type: schema.TypeList, + Optional: true, + MaxItems: 100, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "method": emptySchema(), + "query_string": emptySchema(), + "single_header": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 40), + // The value is returned in lower case by the API. + // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. + validation.StringMatch(regexp.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), + ), + }, }, }, }, + "uri_path": emptySchema(), }, - "uri_path": emptySchema(), }, + Description: "Parts of the request to exclude from logs", + DiffSuppressFunc: suppressRedactedFieldsDiff, }, - Description: "Parts of the request to exclude from logs", - DiffSuppressFunc: suppressRedactedFieldsDiff, - }, - "resource_arn": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidARN, - Description: "AWS WebACL ARN", - }, + "resource_arn": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: verify.ValidARN, + Description: "AWS WebACL ARN", + }, + } }, } } From ff98367040ff5eafbd96cdadd199527018623f20 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 23 Jun 2023 14:08:51 -0400 Subject: [PATCH 04/20] quicksight: Implement 'SchemaFunc()'. --- .../quicksight/account_subscription.go | 182 ++-- internal/service/quicksight/analysis.go | 153 +-- internal/service/quicksight/dashboard.go | 163 +-- internal/service/quicksight/data_set.go | 547 +++++----- .../quicksight/data_set_data_source.go | 362 +++---- internal/service/quicksight/data_source.go | 955 +++++++++--------- internal/service/quicksight/group.go | 70 +- .../service/quicksight/group_data_source.go | 64 +- .../service/quicksight/group_membership.go | 70 +- internal/service/quicksight/template.go | 143 +-- internal/service/quicksight/theme.go | 505 ++++----- .../service/quicksight/theme_data_source.go | 420 ++++---- internal/service/quicksight/user.go | 138 +-- .../service/quicksight/user_data_source.go | 88 +- 14 files changed, 1947 insertions(+), 1913 deletions(-) diff --git a/internal/service/quicksight/account_subscription.go b/internal/service/quicksight/account_subscription.go index 0daa71db9754..38aa424f1196 100644 --- a/internal/service/quicksight/account_subscription.go +++ b/internal/service/quicksight/account_subscription.go @@ -35,96 +35,98 @@ func ResourceAccountSubscription() *schema.Resource { Delete: schema.DefaultTimeout(10 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "account_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "account_subscription_status": { - Type: schema.TypeString, - Computed: true, - }, - "active_directory_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "admin_group": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - ForceNew: true, - }, - "authentication_method": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.AuthenticationMethodOption_Values(), false), - }, - "author_group": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - ForceNew: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "contact_number": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "directory_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "edition": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.Edition_Values(), false), - }, - "email_address": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "first_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "last_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "notification_email": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "reader_group": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "realm": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "account_subscription_status": { + Type: schema.TypeString, + Computed: true, + }, + "active_directory_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "admin_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + "authentication_method": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.AuthenticationMethodOption_Values(), false), + }, + "author_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "contact_number": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "directory_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "edition": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.Edition_Values(), false), + }, + "email_address": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "first_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "last_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "notification_email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "reader_group": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "realm": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + } }, } } diff --git a/internal/service/quicksight/analysis.go b/internal/service/quicksight/analysis.go index 15c7d3d1879d..68a2fcc4cfc9 100644 --- a/internal/service/quicksight/analysis.go +++ b/internal/service/quicksight/analysis.go @@ -51,85 +51,88 @@ func ResourceAnalysis() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "analysis_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "definition": quicksightschema.AnalysisDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "last_published_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "parameters": quicksightschema.ParametersSchema(), - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "analysis_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "definition": quicksightschema.AnalysisDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_published_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "parameters": quicksightschema.ParametersSchema(), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "recovery_window_in_days": { - Type: schema.TypeInt, - Optional: true, - Default: 30, - ValidateFunc: validation.Any( - validation.IntBetween(recoveryWindowInDaysMin, recoveryWindowInDaysMax), - validation.IntInSlice([]int{0}), - ), - }, - "source_entity": quicksightschema.AnalysisSourceEntitySchema(), - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "theme_arn": { - Type: schema.TypeString, - Optional: true, - }, + "recovery_window_in_days": { + Type: schema.TypeInt, + Optional: true, + Default: 30, + ValidateFunc: validation.Any( + validation.IntBetween(recoveryWindowInDaysMin, recoveryWindowInDaysMax), + validation.IntInSlice([]int{0}), + ), + }, + "source_entity": quicksightschema.AnalysisSourceEntitySchema(), + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "theme_arn": { + Type: schema.TypeString, + Optional: true, + }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/dashboard.go b/internal/service/quicksight/dashboard.go index b7d569e06283..418ff5879d40 100644 --- a/internal/service/quicksight/dashboard.go +++ b/internal/service/quicksight/dashboard.go @@ -44,90 +44,93 @@ func ResourceDashboard() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "dashboard_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "dashboard_publish_options": quicksightschema.DashboardPublishOptionsSchema(), - "definition": quicksightschema.DashboardDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "last_published_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "parameters": quicksightschema.ParametersSchema(), - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "dashboard_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "dashboard_publish_options": quicksightschema.DashboardPublishOptionsSchema(), + "definition": quicksightschema.DashboardDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_published_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "parameters": quicksightschema.ParametersSchema(), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "source_entity": quicksightschema.DashboardSourceEntitySchema(), - "source_entity_arn": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "theme_arn": { - Type: schema.TypeString, - Optional: true, - }, - "version_description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "source_entity": quicksightschema.DashboardSourceEntitySchema(), + "source_entity_arn": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "theme_arn": { + Type: schema.TypeString, + Optional: true, + }, + "version_description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, + CustomizeDiff: customdiff.All( refreshOutputsDiff, verify.SetTagsDiff, diff --git a/internal/service/quicksight/data_set.go b/internal/service/quicksight/data_set.go index ff475f777cd8..d8c36e769971 100644 --- a/internal/service/quicksight/data_set.go +++ b/internal/service/quicksight/data_set.go @@ -35,307 +35,309 @@ func ResourceDataSet() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "column_groups": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 8, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "geo_spatial_column_group": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "columns": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{ + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "column_groups": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 8, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "geo_spatial_column_group": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "columns": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + }, + "country_code": { Type: schema.TypeString, - ValidateFunc: validation.StringLenBetween(1, 128), + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.GeoSpatialCountryCode_Values(), false), + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 64), }, - }, - "country_code": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.GeoSpatialCountryCode_Values(), false), - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 64), }, }, }, }, }, }, - }, - "column_level_permission_rules": { - Type: schema.TypeList, - MinItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_names": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principals": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 100, - Elem: &schema.Schema{Type: schema.TypeString}, + "column_level_permission_rules": { + Type: schema.TypeList, + MinItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_names": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principals": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 100, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, }, }, - }, - "data_set_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "data_set_usage_configuration": { - Type: schema.TypeList, - Computed: true, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_use_as_direct_query_source": { - Type: schema.TypeBool, - Computed: true, - Optional: true, - }, - "disable_use_as_imported_source": { - Type: schema.TypeBool, - Computed: true, - Optional: true, + "data_set_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "data_set_usage_configuration": { + Type: schema.TypeList, + Computed: true, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_use_as_direct_query_source": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + }, + "disable_use_as_imported_source": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + }, }, }, }, - }, - "field_folders": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 1000, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "field_folders_id": { - Type: schema.TypeString, - Required: true, - }, - "columns": { - Type: schema.TypeList, - Optional: true, - MaxItems: 5000, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 500), + "field_folders": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 1000, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_folders_id": { + Type: schema.TypeString, + Required: true, + }, + "columns": { + Type: schema.TypeList, + Optional: true, + MaxItems: 5000, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 500), + }, }, }, }, - }, - "import_mode": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.DataSetImportMode_Values(), false), - }, - "logical_table_map": { - Type: schema.TypeSet, - Optional: true, - Computed: true, - MaxItems: 64, - Elem: logicalTableMapSchema(), - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "output_columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "type": { - Type: schema.TypeString, - Computed: true, + "import_mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.DataSetImportMode_Values(), false), + }, + "logical_table_map": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + MaxItems: 64, + Elem: logicalTableMapSchema(), + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "output_columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "physical_table_map": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 32, - Elem: physicalTableMapSchema(), - }, - "row_level_permission_data_set": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "format_version": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionFormatVersion_Values(), false), - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 64), - }, - "permission_policy": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionPolicy_Values(), false), - }, - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + "physical_table_map": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 32, + Elem: physicalTableMapSchema(), + }, + "row_level_permission_data_set": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "format_version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionFormatVersion_Values(), false), + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 64), + }, + "permission_policy": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionPolicy_Values(), false), + }, + "status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + }, }, }, }, - }, - "row_level_permission_tag_configuration": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), - }, - "tag_rules": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 50, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "match_all_value": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "tag_key": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "tag_multi_value_delimiter": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 10), + "row_level_permission_tag_configuration": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + }, + "tag_rules": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 50, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "match_all_value": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "tag_key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "tag_multi_value_delimiter": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 10), + }, }, }, }, }, }, }, - }, - "refresh_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "refresh_configuration": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "incremental_refresh": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "lookback_window": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Required: true, - }, - "size": { - Type: schema.TypeInt, - Required: true, - }, - "size_unit": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.LookbackWindowSizeUnit_Values(), false), + "refresh_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "refresh_configuration": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "incremental_refresh": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "lookback_window": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Required: true, + }, + "size": { + Type: schema.TypeInt, + Required: true, + }, + "size_unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.LookbackWindowSizeUnit_Values(), false), + }, }, }, }, @@ -348,10 +350,11 @@ func ResourceDataSet() *schema.Resource { }, }, }, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, + CustomizeDiff: customdiff.All( func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error { mode := diff.Get("import_mode").(string) diff --git a/internal/service/quicksight/data_set_data_source.go b/internal/service/quicksight/data_set_data_source.go index 24883a7ebf79..2c9fd925dac8 100644 --- a/internal/service/quicksight/data_set_data_source.go +++ b/internal/service/quicksight/data_set_data_source.go @@ -19,214 +19,216 @@ func DataSourceDataSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceDataSetRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidAccountID, - }, - "column_groups": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "geo_spatial_column_group": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: verify.ValidAccountID, + }, + "column_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "geo_spatial_column_group": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "country_code": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, }, - }, - "country_code": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, }, }, }, }, }, }, - }, - "column_level_permission_rules": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_names": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principals": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, + "column_level_permission_rules": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principals": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, }, }, - }, - "data_set_id": { - Type: schema.TypeString, - Required: true, - }, - "data_set_usage_configuration": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_use_as_direct_query_source": { - Type: schema.TypeBool, - Computed: true, - }, - "disable_use_as_imported_source": { - Type: schema.TypeBool, - Computed: true, + "data_set_id": { + Type: schema.TypeString, + Required: true, + }, + "data_set_usage_configuration": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_use_as_direct_query_source": { + Type: schema.TypeBool, + Computed: true, + }, + "disable_use_as_imported_source": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, - }, - "field_folders": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "field_folders_id": { - Type: schema.TypeString, - Computed: true, - }, - "columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": { - Type: schema.TypeString, - Computed: true, + "field_folders": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_folders_id": { + Type: schema.TypeString, + Computed: true, + }, + "columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "import_mode": { - Type: schema.TypeString, - Computed: true, - }, - "logical_table_map": { - Type: schema.TypeSet, - Computed: true, - Elem: logicalTableMapDataSourceSchema(), - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "permissions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Computed: true, + "import_mode": { + Type: schema.TypeString, + Computed: true, + }, + "logical_table_map": { + Type: schema.TypeSet, + Computed: true, + Elem: logicalTableMapDataSourceSchema(), + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "permissions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "physical_table_map": { - Type: schema.TypeSet, - Computed: true, - Elem: physicalTableMapDataSourceSchema(), - }, - "row_level_permission_data_set": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "format_version": { - Type: schema.TypeString, - Computed: true, - }, - "namespace": { - Type: schema.TypeString, - Computed: true, - }, - "permission_policy": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, + "physical_table_map": { + Type: schema.TypeSet, + Computed: true, + Elem: physicalTableMapDataSourceSchema(), + }, + "row_level_permission_data_set": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "format_version": { + Type: schema.TypeString, + Computed: true, + }, + "namespace": { + Type: schema.TypeString, + Computed: true, + }, + "permission_policy": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "row_level_permission_tag_configuration": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Computed: true, - }, - "tag_rules": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Computed: true, - }, - "match_all_value": { - Type: schema.TypeString, - Computed: true, - }, - "tag_key": { - Type: schema.TypeString, - Computed: true, - }, - "tag_multi_value_delimiter": { - Type: schema.TypeString, - Computed: true, + "row_level_permission_tag_configuration": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tag_rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Computed: true, + }, + "match_all_value": { + Type: schema.TypeString, + Computed: true, + }, + "tag_key": { + Type: schema.TypeString, + Computed: true, + }, + "tag_multi_value_delimiter": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "tags": tftags.TagsSchemaComputed(), - "tags_all": { - Type: schema.TypeMap, - Optional: true, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Deprecated: `this attribute has been deprecated`, - }, + "tags": tftags.TagsSchemaComputed(), + "tags_all": { + Type: schema.TypeMap, + Optional: true, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Deprecated: `this attribute has been deprecated`, + }, + } }, } } diff --git a/internal/service/quicksight/data_source.go b/internal/service/quicksight/data_source.go index 1a2c6f5d1c5f..3c0f28217319 100644 --- a/internal/service/quicksight/data_source.go +++ b/internal/service/quicksight/data_source.go @@ -31,574 +31,577 @@ func ResourceDataSource() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, - "credentials": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "copy_source_arn": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidARN, - ConflictsWith: []string{"credentials.0.credential_pair"}, - }, - "credential_pair": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "password": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 1024), - ), - Sensitive: true, - }, - "username": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 64), - ), - Sensitive: true, + "credentials": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "copy_source_arn": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: verify.ValidARN, + ConflictsWith: []string{"credentials.0.credential_pair"}, + }, + "credential_pair": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "password": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 1024), + ), + Sensitive: true, + }, + "username": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 64), + ), + Sensitive: true, + }, }, }, + ConflictsWith: []string{"credentials.0.copy_source_arn"}, }, - ConflictsWith: []string{"credentials.0.copy_source_arn"}, }, }, }, - }, - "data_source_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "data_source_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 128), - ), - }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 128), + ), + }, - "parameters": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "amazon_elasticsearch": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "domain": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "parameters": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "amazon_elasticsearch": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "domain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "athena": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "work_group": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, + "athena": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "work_group": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "aurora": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "aurora": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "aurora_postgresql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "aurora_postgresql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "aws_iot_analytics": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_set_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "aws_iot_analytics": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_set_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "jira": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "site_base_url": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "jira": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "site_base_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "maria_db": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "maria_db": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "mysql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "mysql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "oracle": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "oracle": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "postgresql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "postgresql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "presto": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "catalog": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "presto": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "catalog": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "rds": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "instance_id": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "rds": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "instance_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "redshift": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Optional: true, - }, - "port": { - Type: schema.TypeInt, - Optional: true, + "redshift": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Optional: true, + }, + "port": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "s3": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "manifest_file_location": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "bucket": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "key": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "s3": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "manifest_file_location": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bucket": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, }, }, }, - }, - "service_now": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "site_base_url": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "service_now": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "site_base_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "snowflake": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "warehouse": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "snowflake": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "warehouse": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "spark": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "spark": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "sql_server": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "sql_server": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "teradata": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "teradata": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "twitter": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "max_rows": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - "query": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "twitter": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "max_rows": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "query": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, }, }, }, - }, - "permission": { - Type: schema.TypeSet, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - MinItems: 1, - MaxItems: 16, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, + "permission": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + MaxItems: 16, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, }, }, }, - }, - "ssl_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_ssl": { - Type: schema.TypeBool, - Required: true, + "ssl_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_ssl": { + Type: schema.TypeBool, + Required: true, + }, }, }, }, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), - "type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.DataSourceType_Values(), false), - }, + "type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.DataSourceType_Values(), false), + }, - "vpc_connection_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "vpc_connection_arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, + "vpc_connection_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vpc_connection_arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, }, }, }, - }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/group.go b/internal/service/quicksight/group.go index 06000416a678..0911b6a822f2 100644 --- a/internal/service/quicksight/group.go +++ b/internal/service/quicksight/group.go @@ -33,40 +33,42 @@ func ResourceGroup() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "description": { - Type: schema.TypeString, - Optional: true, - }, - - "group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: DefaultGroupNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + }, + + "group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: DefaultGroupNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + } }, } } diff --git a/internal/service/quicksight/group_data_source.go b/internal/service/quicksight/group_data_source.go index 20a91847c3aa..0a5438608735 100644 --- a/internal/service/quicksight/group_data_source.go +++ b/internal/service/quicksight/group_data_source.go @@ -20,37 +20,39 @@ func DataSourceGroup() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceGroupRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "group_name": { - Type: schema.TypeString, - Required: true, - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - Default: DefaultGroupNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - "principal_id": { - Type: schema.TypeString, - Computed: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "group_name": { + Type: schema.TypeString, + Required: true, + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + Default: DefaultGroupNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, + } }, } } diff --git a/internal/service/quicksight/group_membership.go b/internal/service/quicksight/group_membership.go index 584559505b85..ba31ca9e5f65 100644 --- a/internal/service/quicksight/group_membership.go +++ b/internal/service/quicksight/group_membership.go @@ -26,40 +26,42 @@ func ResourceGroupMembership() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "member_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: "default", - ValidateFunc: validation.StringInSlice([]string{ - "default", - }, false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "member_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "default", + ValidateFunc: validation.StringInSlice([]string{ + "default", + }, false), + }, + } }, } } diff --git a/internal/service/quicksight/template.go b/internal/service/quicksight/template.go index 2e5227849d5d..5ca5b56d1b87 100644 --- a/internal/service/quicksight/template.go +++ b/internal/service/quicksight/template.go @@ -42,80 +42,83 @@ func ResourceTemplate() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "definition": quicksightschema.TemplateDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "definition": quicksightschema.TemplateDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "source_entity": quicksightschema.TemplateSourceEntitySchema(), - "source_entity_arn": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "template_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "version_description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "source_entity": quicksightschema.TemplateSourceEntitySchema(), + "source_entity_arn": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "template_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "version_description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/theme.go b/internal/service/quicksight/theme.go index a8c8ad9441e1..4fd97b6f0f3d 100644 --- a/internal/service/quicksight/theme.go +++ b/internal/service/quicksight/theme.go @@ -43,118 +43,120 @@ func ResourceTheme() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "base_theme_id": { - Type: schema.TypeString, - Required: true, - }, - "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "colors": { - Type: schema.TypeList, - Optional: true, - MinItems: 8, // Colors size needs to be in the range between 8 and 20 - MaxItems: 20, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "base_theme_id": { + Type: schema.TypeString, + Required: true, + }, + "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "colors": { + Type: schema.TypeList, + Optional: true, + MinItems: 8, // Colors size needs to be in the range between 8 and 20 + MaxItems: 20, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, }, - }, - "empty_fill_color": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "min_max_gradient": { - Type: schema.TypeList, - Optional: true, - MinItems: 2, // MinMaxGradient size needs to be 2 - MaxItems: 2, - Elem: &schema.Schema{ + "empty_fill_color": { Type: schema.TypeString, + Optional: true, ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), }, + "min_max_gradient": { + Type: schema.TypeList, + Optional: true, + MinItems: 2, // MinMaxGradient size needs to be 2 + MaxItems: 2, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + }, }, }, }, - }, - "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, + "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, }, }, }, - }, - "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, + "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, - }, - "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, + "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, @@ -164,177 +166,178 @@ func ResourceTheme() *schema.Resource { }, }, }, - }, - "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html - Type: schema.TypeList, - MaxItems: 5, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_family": { - Type: schema.TypeString, - Optional: true, + "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html + Type: schema.TypeList, + MaxItems: 5, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_family": { + Type: schema.TypeString, + Optional: true, + }, }, }, }, }, }, }, - }, - "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accent": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "accent_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "danger": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "danger_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "dimension": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "dimension_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "measure": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "measure_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "primary_background": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "primary_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "secondary_background": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "secondary_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "success": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "success_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "warning": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "warning_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accent": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "accent_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "danger": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "danger_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "dimension": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "dimension_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "measure": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "measure_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "primary_background": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "primary_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "secondary_background": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "secondary_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "success": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "success_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "warning": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "warning_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, }, }, }, }, }, }, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "theme_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "theme_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "version_description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "version_description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/theme_data_source.go b/internal/service/quicksight/theme_data_source.go index b0f55c3bd6bf..b4fb24895a8d 100644 --- a/internal/service/quicksight/theme_data_source.go +++ b/internal/service/quicksight/theme_data_source.go @@ -20,102 +20,104 @@ func DataSourceTheme() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceThemeRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidAccountID, - }, - "base_theme_id": { - Type: schema.TypeString, - Computed: true, - }, - "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "colors": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: verify.ValidAccountID, + }, + "base_theme_id": { + Type: schema.TypeString, + Computed: true, + }, + "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "colors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - }, - "empty_fill_color": { - Type: schema.TypeString, - Computed: true, - }, - "min_max_gradient": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + "empty_fill_color": { + Type: schema.TypeString, + Computed: true, + }, + "min_max_gradient": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, }, - }, - "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, + "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, }, }, }, - }, - "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, + "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, - }, - "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, + "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, @@ -125,148 +127,148 @@ func DataSourceTheme() *schema.Resource { }, }, }, - }, - "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_family": { - Type: schema.TypeString, - Computed: true, + "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_family": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accent": { - Type: schema.TypeString, - Computed: true, - }, - "accent_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "danger": { - Type: schema.TypeString, - Computed: true, - }, - "danger_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "dimension": { - Type: schema.TypeString, - Computed: true, - }, - "dimension_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "measure": { - Type: schema.TypeString, - Computed: true, - }, - "measure_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "primary_background": { - Type: schema.TypeString, - Computed: true, - }, - "primary_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_background": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "success": { - Type: schema.TypeString, - Computed: true, - }, - "success_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "warning": { - Type: schema.TypeString, - Computed: true, - }, - "warning_foreground": { - Type: schema.TypeString, - Computed: true, + "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accent": { + Type: schema.TypeString, + Computed: true, + }, + "accent_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "danger": { + Type: schema.TypeString, + Computed: true, + }, + "danger_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "dimension": { + Type: schema.TypeString, + Computed: true, + }, + "dimension_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "measure": { + Type: schema.TypeString, + Computed: true, + }, + "measure_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "primary_background": { + Type: schema.TypeString, + Computed: true, + }, + "primary_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_background": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "success": { + Type: schema.TypeString, + Computed: true, + }, + "success_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "warning": { + Type: schema.TypeString, + Computed: true, + }, + "warning_foreground": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "theme_id": { - Type: schema.TypeString, - Required: true, - }, - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "permissions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Computed: true, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "theme_id": { + Type: schema.TypeString, + Required: true, + }, + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "permissions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchemaComputed(), - "version_description": { - Type: schema.TypeString, - Computed: true, - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchemaComputed(), + "version_description": { + Type: schema.TypeString, + Computed: true, + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, } } diff --git a/internal/service/quicksight/user.go b/internal/service/quicksight/user.go index de7078030daf..5c1c991f818e 100644 --- a/internal/service/quicksight/user.go +++ b/internal/service/quicksight/user.go @@ -29,74 +29,76 @@ func ResourceUser() *schema.Resource { UpdateWithoutTimeout: resourceUserUpdate, DeleteWithoutTimeout: resourceUserDelete, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "email": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "iam_arn": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "identity_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - quicksight.IdentityTypeIam, - quicksight.IdentityTypeQuicksight, - }, false), - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: DefaultUserNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - - "session_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "user_name": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, - - "user_role": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - quicksight.UserRoleReader, - quicksight.UserRoleAuthor, - quicksight.UserRoleAdmin, - }, false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "iam_arn": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "identity_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + quicksight.IdentityTypeIam, + quicksight.IdentityTypeQuicksight, + }, false), + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: DefaultUserNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + + "session_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "user_name": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, + + "user_role": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + quicksight.UserRoleReader, + quicksight.UserRoleAuthor, + quicksight.UserRoleAdmin, + }, false), + }, + } }, } } diff --git a/internal/service/quicksight/user_data_source.go b/internal/service/quicksight/user_data_source.go index 5e987f74fc9c..a0bcd63bad35 100644 --- a/internal/service/quicksight/user_data_source.go +++ b/internal/service/quicksight/user_data_source.go @@ -20,49 +20,51 @@ func DataSourceUser() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceUserRead, - Schema: map[string]*schema.Schema{ - "active": { - Type: schema.TypeBool, - Computed: true, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "email": { - Type: schema.TypeString, - Computed: true, - }, - "identity_type": { - Type: schema.TypeString, - Computed: true, - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - Default: DefaultUserNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - "principal_id": { - Type: schema.TypeString, - Computed: true, - }, - "user_name": { - Type: schema.TypeString, - Required: true, - }, - "user_role": { - Type: schema.TypeString, - Computed: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "active": { + Type: schema.TypeBool, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "email": { + Type: schema.TypeString, + Computed: true, + }, + "identity_type": { + Type: schema.TypeString, + Computed: true, + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + Default: DefaultUserNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, + "user_name": { + Type: schema.TypeString, + Required: true, + }, + "user_role": { + Type: schema.TypeString, + Computed: true, + }, + } }, } } From 001bc4f99ae0fb1942d359fc836486e671bd32da Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 23 Jun 2023 14:22:36 -0400 Subject: [PATCH 05/20] Only do schema checking for transparent tagging if it isn't lazy-loaded. --- internal/provider/provider.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index daf8c128803c..fa9a850e5aa3 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -323,25 +323,27 @@ func New(ctx context.Context) (*schema.Provider, error) { interceptors := interceptorItems{} if v.Tags != nil { - // The resource has opted in to transparent tagging. - // Ensure that the schema look OK. - if v, ok := r.Schema[names.AttrTags]; ok { - if v.Computed { - errs = multierror.Append(errs, fmt.Errorf("`%s` attribute cannot be Computed: %s", names.AttrTags, typeName)) + if r.SchemaFunc == nil { + // The resource has opted in to transparent tagging. + // Ensure that the schema look OK. + if v, ok := r.Schema[names.AttrTags]; ok { + if v.Computed { + errs = multierror.Append(errs, fmt.Errorf("`%s` attribute cannot be Computed: %s", names.AttrTags, typeName)) + continue + } + } else { + errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTags, typeName)) continue } - } else { - errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTags, typeName)) - continue - } - if v, ok := r.Schema[names.AttrTagsAll]; ok { - if !v.Computed { - errs = multierror.Append(errs, fmt.Errorf("`%s` attribute must be Computed: %s", names.AttrTags, typeName)) + if v, ok := r.Schema[names.AttrTagsAll]; ok { + if !v.Computed { + errs = multierror.Append(errs, fmt.Errorf("`%s` attribute must be Computed: %s", names.AttrTags, typeName)) + continue + } + } else { + errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTagsAll, typeName)) continue } - } else { - errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTagsAll, typeName)) - continue } interceptors = append(interceptors, interceptorItem{ From 59cb145e210d112b6939208fd45f54ca4e96dad1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 09:31:06 -0400 Subject: [PATCH 06/20] Revert "quicksight: Implement 'SchemaFunc()'." This reverts commit ff98367040ff5eafbd96cdadd199527018623f20. --- .../quicksight/account_subscription.go | 182 ++-- internal/service/quicksight/analysis.go | 153 ++- internal/service/quicksight/dashboard.go | 163 ++- internal/service/quicksight/data_set.go | 547 +++++----- .../quicksight/data_set_data_source.go | 362 ++++--- internal/service/quicksight/data_source.go | 955 +++++++++--------- internal/service/quicksight/group.go | 70 +- .../service/quicksight/group_data_source.go | 64 +- .../service/quicksight/group_membership.go | 70 +- internal/service/quicksight/template.go | 143 ++- internal/service/quicksight/theme.go | 505 +++++---- .../service/quicksight/theme_data_source.go | 420 ++++---- internal/service/quicksight/user.go | 138 ++- .../service/quicksight/user_data_source.go | 88 +- 14 files changed, 1913 insertions(+), 1947 deletions(-) diff --git a/internal/service/quicksight/account_subscription.go b/internal/service/quicksight/account_subscription.go index 38aa424f1196..0daa71db9754 100644 --- a/internal/service/quicksight/account_subscription.go +++ b/internal/service/quicksight/account_subscription.go @@ -35,98 +35,96 @@ func ResourceAccountSubscription() *schema.Resource { Delete: schema.DefaultTimeout(10 * time.Minute), }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "account_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "account_subscription_status": { - Type: schema.TypeString, - Computed: true, - }, - "active_directory_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "admin_group": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - ForceNew: true, - }, - "authentication_method": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.AuthenticationMethodOption_Values(), false), - }, - "author_group": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - ForceNew: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "contact_number": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "directory_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "edition": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.Edition_Values(), false), - }, - "email_address": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "first_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "last_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "notification_email": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "reader_group": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "realm": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - } + Schema: map[string]*schema.Schema{ + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "account_subscription_status": { + Type: schema.TypeString, + Computed: true, + }, + "active_directory_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "admin_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + "authentication_method": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.AuthenticationMethodOption_Values(), false), + }, + "author_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "contact_number": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "directory_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "edition": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.Edition_Values(), false), + }, + "email_address": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "first_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "last_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "notification_email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "reader_group": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "realm": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } diff --git a/internal/service/quicksight/analysis.go b/internal/service/quicksight/analysis.go index 68a2fcc4cfc9..15c7d3d1879d 100644 --- a/internal/service/quicksight/analysis.go +++ b/internal/service/quicksight/analysis.go @@ -51,88 +51,85 @@ func ResourceAnalysis() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "analysis_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "definition": quicksightschema.AnalysisDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "last_published_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "parameters": quicksightschema.ParametersSchema(), - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "analysis_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "definition": quicksightschema.AnalysisDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_published_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "parameters": quicksightschema.ParametersSchema(), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), }, }, }, - "recovery_window_in_days": { - Type: schema.TypeInt, - Optional: true, - Default: 30, - ValidateFunc: validation.Any( - validation.IntBetween(recoveryWindowInDaysMin, recoveryWindowInDaysMax), - validation.IntInSlice([]int{0}), - ), - }, - "source_entity": quicksightschema.AnalysisSourceEntitySchema(), - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "theme_arn": { - Type: schema.TypeString, - Optional: true, - }, - } + }, + "recovery_window_in_days": { + Type: schema.TypeInt, + Optional: true, + Default: 30, + ValidateFunc: validation.Any( + validation.IntBetween(recoveryWindowInDaysMin, recoveryWindowInDaysMax), + validation.IntInSlice([]int{0}), + ), + }, + "source_entity": quicksightschema.AnalysisSourceEntitySchema(), + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "theme_arn": { + Type: schema.TypeString, + Optional: true, + }, }, - CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/dashboard.go b/internal/service/quicksight/dashboard.go index 418ff5879d40..b7d569e06283 100644 --- a/internal/service/quicksight/dashboard.go +++ b/internal/service/quicksight/dashboard.go @@ -44,93 +44,90 @@ func ResourceDashboard() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "dashboard_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "dashboard_publish_options": quicksightschema.DashboardPublishOptionsSchema(), - "definition": quicksightschema.DashboardDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "last_published_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "parameters": quicksightschema.ParametersSchema(), - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "dashboard_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "dashboard_publish_options": quicksightschema.DashboardPublishOptionsSchema(), + "definition": quicksightschema.DashboardDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_published_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "parameters": quicksightschema.ParametersSchema(), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), }, }, }, - "source_entity": quicksightschema.DashboardSourceEntitySchema(), - "source_entity_arn": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "theme_arn": { - Type: schema.TypeString, - Optional: true, - }, - "version_description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, - } + }, + "source_entity": quicksightschema.DashboardSourceEntitySchema(), + "source_entity_arn": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "theme_arn": { + Type: schema.TypeString, + Optional: true, + }, + "version_description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, }, - CustomizeDiff: customdiff.All( refreshOutputsDiff, verify.SetTagsDiff, diff --git a/internal/service/quicksight/data_set.go b/internal/service/quicksight/data_set.go index d8c36e769971..ff475f777cd8 100644 --- a/internal/service/quicksight/data_set.go +++ b/internal/service/quicksight/data_set.go @@ -35,309 +35,307 @@ func ResourceDataSet() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "column_groups": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 8, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "geo_spatial_column_group": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "columns": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - }, - "country_code": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.GeoSpatialCountryCode_Values(), false), - }, - "name": { + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "column_groups": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 8, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "geo_spatial_column_group": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "columns": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{ Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 64), + ValidateFunc: validation.StringLenBetween(1, 128), }, }, + "country_code": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.GeoSpatialCountryCode_Values(), false), + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 64), + }, }, }, }, }, }, - "column_level_permission_rules": { - Type: schema.TypeList, - MinItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_names": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principals": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 100, - Elem: &schema.Schema{Type: schema.TypeString}, - }, + }, + "column_level_permission_rules": { + Type: schema.TypeList, + MinItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_names": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principals": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 100, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, - "data_set_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "data_set_usage_configuration": { - Type: schema.TypeList, - Computed: true, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_use_as_direct_query_source": { - Type: schema.TypeBool, - Computed: true, - Optional: true, - }, - "disable_use_as_imported_source": { - Type: schema.TypeBool, - Computed: true, - Optional: true, - }, + }, + "data_set_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "data_set_usage_configuration": { + Type: schema.TypeList, + Computed: true, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_use_as_direct_query_source": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + }, + "disable_use_as_imported_source": { + Type: schema.TypeBool, + Computed: true, + Optional: true, }, }, }, - "field_folders": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 1000, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "field_folders_id": { - Type: schema.TypeString, - Required: true, - }, - "columns": { - Type: schema.TypeList, - Optional: true, - MaxItems: 5000, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 500), - }, + }, + "field_folders": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 1000, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_folders_id": { + Type: schema.TypeString, + Required: true, + }, + "columns": { + Type: schema.TypeList, + Optional: true, + MaxItems: 5000, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 500), }, }, }, - "import_mode": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.DataSetImportMode_Values(), false), - }, - "logical_table_map": { - Type: schema.TypeSet, - Optional: true, - Computed: true, - MaxItems: 64, - Elem: logicalTableMapSchema(), - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "output_columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "type": { - Type: schema.TypeString, - Computed: true, - }, + }, + "import_mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.DataSetImportMode_Values(), false), + }, + "logical_table_map": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + MaxItems: 64, + Elem: logicalTableMapSchema(), + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "output_columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, }, }, }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), }, }, }, - "physical_table_map": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 32, - Elem: physicalTableMapSchema(), - }, - "row_level_permission_data_set": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "format_version": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionFormatVersion_Values(), false), - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 64), - }, - "permission_policy": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionPolicy_Values(), false), - }, - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), - }, + }, + "physical_table_map": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 32, + Elem: physicalTableMapSchema(), + }, + "row_level_permission_data_set": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "format_version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionFormatVersion_Values(), false), + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 64), + }, + "permission_policy": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionPolicy_Values(), false), + }, + "status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), }, }, }, - "row_level_permission_tag_configuration": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), - }, - "tag_rules": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 50, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "match_all_value": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "tag_key": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "tag_multi_value_delimiter": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 10), - }, + }, + "row_level_permission_tag_configuration": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + }, + "tag_rules": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 50, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "match_all_value": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "tag_key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "tag_multi_value_delimiter": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 10), }, }, }, }, }, }, - "refresh_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "refresh_configuration": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "incremental_refresh": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "lookback_window": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Required: true, - }, - "size": { - Type: schema.TypeInt, - Required: true, - }, - "size_unit": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.LookbackWindowSizeUnit_Values(), false), - }, + }, + "refresh_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "refresh_configuration": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "incremental_refresh": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "lookback_window": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Required: true, + }, + "size": { + Type: schema.TypeInt, + Required: true, + }, + "size_unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.LookbackWindowSizeUnit_Values(), false), }, }, }, @@ -350,11 +348,10 @@ func ResourceDataSet() *schema.Resource { }, }, }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - } + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, - CustomizeDiff: customdiff.All( func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error { mode := diff.Get("import_mode").(string) diff --git a/internal/service/quicksight/data_set_data_source.go b/internal/service/quicksight/data_set_data_source.go index 2c9fd925dac8..24883a7ebf79 100644 --- a/internal/service/quicksight/data_set_data_source.go +++ b/internal/service/quicksight/data_set_data_source.go @@ -19,216 +19,214 @@ func DataSourceDataSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceDataSetRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidAccountID, - }, - "column_groups": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "geo_spatial_column_group": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "country_code": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: verify.ValidAccountID, + }, + "column_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "geo_spatial_column_group": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, + "country_code": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, - "column_level_permission_rules": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_names": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principals": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, + }, + "column_level_permission_rules": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principals": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, - "data_set_id": { - Type: schema.TypeString, - Required: true, - }, - "data_set_usage_configuration": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_use_as_direct_query_source": { - Type: schema.TypeBool, - Computed: true, - }, - "disable_use_as_imported_source": { - Type: schema.TypeBool, - Computed: true, - }, + }, + "data_set_id": { + Type: schema.TypeString, + Required: true, + }, + "data_set_usage_configuration": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_use_as_direct_query_source": { + Type: schema.TypeBool, + Computed: true, + }, + "disable_use_as_imported_source": { + Type: schema.TypeBool, + Computed: true, }, }, }, - "field_folders": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "field_folders_id": { - Type: schema.TypeString, - Computed: true, - }, - "columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, + }, + "field_folders": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_folders_id": { + Type: schema.TypeString, + Computed: true, + }, + "columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": { + Type: schema.TypeString, + Computed: true, }, }, }, - "import_mode": { - Type: schema.TypeString, - Computed: true, - }, - "logical_table_map": { - Type: schema.TypeSet, - Computed: true, - Elem: logicalTableMapDataSourceSchema(), - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "permissions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Computed: true, - }, + }, + "import_mode": { + Type: schema.TypeString, + Computed: true, + }, + "logical_table_map": { + Type: schema.TypeSet, + Computed: true, + Elem: logicalTableMapDataSourceSchema(), + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "permissions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Computed: true, }, }, }, - "physical_table_map": { - Type: schema.TypeSet, - Computed: true, - Elem: physicalTableMapDataSourceSchema(), - }, - "row_level_permission_data_set": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "format_version": { - Type: schema.TypeString, - Computed: true, - }, - "namespace": { - Type: schema.TypeString, - Computed: true, - }, - "permission_policy": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, + }, + "physical_table_map": { + Type: schema.TypeSet, + Computed: true, + Elem: physicalTableMapDataSourceSchema(), + }, + "row_level_permission_data_set": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "format_version": { + Type: schema.TypeString, + Computed: true, + }, + "namespace": { + Type: schema.TypeString, + Computed: true, + }, + "permission_policy": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, }, }, }, - "row_level_permission_tag_configuration": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Computed: true, - }, - "tag_rules": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Computed: true, - }, - "match_all_value": { - Type: schema.TypeString, - Computed: true, - }, - "tag_key": { - Type: schema.TypeString, - Computed: true, - }, - "tag_multi_value_delimiter": { - Type: schema.TypeString, - Computed: true, - }, + }, + "row_level_permission_tag_configuration": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tag_rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Computed: true, + }, + "match_all_value": { + Type: schema.TypeString, + Computed: true, + }, + "tag_key": { + Type: schema.TypeString, + Computed: true, + }, + "tag_multi_value_delimiter": { + Type: schema.TypeString, + Computed: true, }, }, }, }, }, }, - "tags": tftags.TagsSchemaComputed(), - "tags_all": { - Type: schema.TypeMap, - Optional: true, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Deprecated: `this attribute has been deprecated`, - }, - } + }, + "tags": tftags.TagsSchemaComputed(), + "tags_all": { + Type: schema.TypeMap, + Optional: true, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Deprecated: `this attribute has been deprecated`, + }, }, } } diff --git a/internal/service/quicksight/data_source.go b/internal/service/quicksight/data_source.go index 3c0f28217319..1a2c6f5d1c5f 100644 --- a/internal/service/quicksight/data_source.go +++ b/internal/service/quicksight/data_source.go @@ -31,577 +31,574 @@ func ResourceDataSource() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, - "credentials": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "copy_source_arn": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidARN, - ConflictsWith: []string{"credentials.0.credential_pair"}, - }, - "credential_pair": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "password": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 1024), - ), - Sensitive: true, - }, - "username": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 64), - ), - Sensitive: true, - }, + "credentials": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "copy_source_arn": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: verify.ValidARN, + ConflictsWith: []string{"credentials.0.credential_pair"}, + }, + "credential_pair": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "password": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 1024), + ), + Sensitive: true, + }, + "username": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 64), + ), + Sensitive: true, }, }, - ConflictsWith: []string{"credentials.0.copy_source_arn"}, }, + ConflictsWith: []string{"credentials.0.copy_source_arn"}, }, }, }, + }, - "data_source_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "data_source_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 128), - ), - }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 128), + ), + }, - "parameters": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "amazon_elasticsearch": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "domain": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + "parameters": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "amazon_elasticsearch": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "domain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "athena": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "work_group": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "athena": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "work_group": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "aurora": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "aurora": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "aurora_postgresql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "aurora_postgresql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "aws_iot_analytics": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_set_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "aws_iot_analytics": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_set_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "jira": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "site_base_url": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "jira": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "site_base_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "maria_db": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "maria_db": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "mysql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "mysql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "oracle": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "oracle": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "postgresql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "postgresql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "presto": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "catalog": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "presto": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "catalog": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "rds": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "instance_id": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "rds": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "instance_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "redshift": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Optional: true, - }, - "port": { - Type: schema.TypeInt, - Optional: true, - }, + }, + "redshift": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Optional: true, + }, + "port": { + Type: schema.TypeInt, + Optional: true, }, }, }, - "s3": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "manifest_file_location": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "bucket": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "key": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "s3": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "manifest_file_location": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bucket": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, }, }, }, - "service_now": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "site_base_url": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "service_now": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "site_base_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "snowflake": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "warehouse": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "snowflake": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "warehouse": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, - "spark": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "spark": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "sql_server": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "sql_server": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "teradata": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, + }, + "teradata": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), }, }, }, - "twitter": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "max_rows": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - "query": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, + }, + "twitter": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "max_rows": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "query": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, }, }, }, }, }, }, + }, - "permission": { - Type: schema.TypeSet, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - MinItems: 1, - MaxItems: 16, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, + "permission": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + MaxItems: 16, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, }, }, }, + }, - "ssl_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_ssl": { - Type: schema.TypeBool, - Required: true, - }, + "ssl_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_ssl": { + Type: schema.TypeBool, + Required: true, }, }, }, + }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), - "type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.DataSourceType_Values(), false), - }, + "type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.DataSourceType_Values(), false), + }, - "vpc_connection_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "vpc_connection_arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, + "vpc_connection_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vpc_connection_arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, }, }, }, - } + }, }, - CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/group.go b/internal/service/quicksight/group.go index 0911b6a822f2..06000416a678 100644 --- a/internal/service/quicksight/group.go +++ b/internal/service/quicksight/group.go @@ -33,42 +33,40 @@ func ResourceGroup() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "description": { - Type: schema.TypeString, - Optional: true, - }, - - "group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: DefaultGroupNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - } + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + }, + + "group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: DefaultGroupNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, }, } } diff --git a/internal/service/quicksight/group_data_source.go b/internal/service/quicksight/group_data_source.go index 0a5438608735..20a91847c3aa 100644 --- a/internal/service/quicksight/group_data_source.go +++ b/internal/service/quicksight/group_data_source.go @@ -20,39 +20,37 @@ func DataSourceGroup() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceGroupRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "group_name": { - Type: schema.TypeString, - Required: true, - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - Default: DefaultGroupNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - "principal_id": { - Type: schema.TypeString, - Computed: true, - }, - } + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "group_name": { + Type: schema.TypeString, + Required: true, + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + Default: DefaultGroupNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, }, } } diff --git a/internal/service/quicksight/group_membership.go b/internal/service/quicksight/group_membership.go index ba31ca9e5f65..584559505b85 100644 --- a/internal/service/quicksight/group_membership.go +++ b/internal/service/quicksight/group_membership.go @@ -26,42 +26,40 @@ func ResourceGroupMembership() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "member_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: "default", - ValidateFunc: validation.StringInSlice([]string{ - "default", - }, false), - }, - } + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "member_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "default", + ValidateFunc: validation.StringInSlice([]string{ + "default", + }, false), + }, }, } } diff --git a/internal/service/quicksight/template.go b/internal/service/quicksight/template.go index 5ca5b56d1b87..2e5227849d5d 100644 --- a/internal/service/quicksight/template.go +++ b/internal/service/quicksight/template.go @@ -42,83 +42,80 @@ func ResourceTemplate() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "definition": quicksightschema.TemplateDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "definition": quicksightschema.TemplateDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), }, }, }, - "source_entity": quicksightschema.TemplateSourceEntitySchema(), - "source_entity_arn": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "template_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "version_description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, - } + }, + "source_entity": quicksightschema.TemplateSourceEntitySchema(), + "source_entity_arn": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "template_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "version_description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, }, - CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/theme.go b/internal/service/quicksight/theme.go index 4fd97b6f0f3d..a8c8ad9441e1 100644 --- a/internal/service/quicksight/theme.go +++ b/internal/service/quicksight/theme.go @@ -43,120 +43,118 @@ func ResourceTheme() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "base_theme_id": { - Type: schema.TypeString, - Required: true, - }, - "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "colors": { - Type: schema.TypeList, - Optional: true, - MinItems: 8, // Colors size needs to be in the range between 8 and 20 - MaxItems: 20, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - }, - "empty_fill_color": { + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "base_theme_id": { + Type: schema.TypeString, + Required: true, + }, + "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "colors": { + Type: schema.TypeList, + Optional: true, + MinItems: 8, // Colors size needs to be in the range between 8 and 20 + MaxItems: 20, + Elem: &schema.Schema{ Type: schema.TypeString, - Optional: true, ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), }, - "min_max_gradient": { - Type: schema.TypeList, - Optional: true, - MinItems: 2, // MinMaxGradient size needs to be 2 - MaxItems: 2, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, + }, + "empty_fill_color": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "min_max_gradient": { + Type: schema.TypeList, + Optional: true, + MinItems: 2, // MinMaxGradient size needs to be 2 + MaxItems: 2, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), }, }, }, }, - "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, }, }, }, }, }, }, - "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, }, }, }, @@ -166,178 +164,177 @@ func ResourceTheme() *schema.Resource { }, }, }, - "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html - Type: schema.TypeList, - MaxItems: 5, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_family": { - Type: schema.TypeString, - Optional: true, - }, + }, + "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html + Type: schema.TypeList, + MaxItems: 5, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_family": { + Type: schema.TypeString, + Optional: true, }, }, }, }, }, }, - "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accent": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "accent_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "danger": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "danger_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "dimension": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "dimension_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "measure": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "measure_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "primary_background": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "primary_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "secondary_background": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "secondary_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "success": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "success_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "warning": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "warning_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, + }, + "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accent": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "accent_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "danger": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "danger_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "dimension": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "dimension_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "measure": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "measure_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "primary_background": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "primary_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "secondary_background": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "secondary_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "success": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "success_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "warning": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "warning_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), }, }, }, }, }, }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "theme_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "theme_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), }, }, }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "version_description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, - } + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "version_description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, }, - CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/theme_data_source.go b/internal/service/quicksight/theme_data_source.go index b4fb24895a8d..b0f55c3bd6bf 100644 --- a/internal/service/quicksight/theme_data_source.go +++ b/internal/service/quicksight/theme_data_source.go @@ -20,104 +20,102 @@ func DataSourceTheme() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceThemeRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidAccountID, - }, - "base_theme_id": { - Type: schema.TypeString, - Computed: true, - }, - "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "colors": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: verify.ValidAccountID, + }, + "base_theme_id": { + Type: schema.TypeString, + Computed: true, + }, + "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "colors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "empty_fill_color": { - Type: schema.TypeString, - Computed: true, - }, - "min_max_gradient": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "empty_fill_color": { + Type: schema.TypeString, + Computed: true, + }, + "min_max_gradient": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, }, }, - "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, - }, + }, + "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, }, }, }, }, }, }, - "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, - }, + }, + "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, }, }, }, - "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, - }, + }, + "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, }, }, }, @@ -127,148 +125,148 @@ func DataSourceTheme() *schema.Resource { }, }, }, - "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_family": { - Type: schema.TypeString, - Computed: true, - }, + }, + "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_family": { + Type: schema.TypeString, + Computed: true, }, }, }, }, }, }, - "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accent": { - Type: schema.TypeString, - Computed: true, - }, - "accent_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "danger": { - Type: schema.TypeString, - Computed: true, - }, - "danger_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "dimension": { - Type: schema.TypeString, - Computed: true, - }, - "dimension_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "measure": { - Type: schema.TypeString, - Computed: true, - }, - "measure_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "primary_background": { - Type: schema.TypeString, - Computed: true, - }, - "primary_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_background": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "success": { - Type: schema.TypeString, - Computed: true, - }, - "success_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "warning": { - Type: schema.TypeString, - Computed: true, - }, - "warning_foreground": { - Type: schema.TypeString, - Computed: true, - }, + }, + "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accent": { + Type: schema.TypeString, + Computed: true, + }, + "accent_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "danger": { + Type: schema.TypeString, + Computed: true, + }, + "danger_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "dimension": { + Type: schema.TypeString, + Computed: true, + }, + "dimension_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "measure": { + Type: schema.TypeString, + Computed: true, + }, + "measure_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "primary_background": { + Type: schema.TypeString, + Computed: true, + }, + "primary_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_background": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "success": { + Type: schema.TypeString, + Computed: true, + }, + "success_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "warning": { + Type: schema.TypeString, + Computed: true, + }, + "warning_foreground": { + Type: schema.TypeString, + Computed: true, }, }, }, }, }, }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "theme_id": { - Type: schema.TypeString, - Required: true, - }, - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "permissions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Computed: true, - }, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "theme_id": { + Type: schema.TypeString, + Required: true, + }, + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "permissions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Computed: true, }, }, }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchemaComputed(), - "version_description": { - Type: schema.TypeString, - Computed: true, - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, - } + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchemaComputed(), + "version_description": { + Type: schema.TypeString, + Computed: true, + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, }, } } diff --git a/internal/service/quicksight/user.go b/internal/service/quicksight/user.go index 5c1c991f818e..de7078030daf 100644 --- a/internal/service/quicksight/user.go +++ b/internal/service/quicksight/user.go @@ -29,76 +29,74 @@ func ResourceUser() *schema.Resource { UpdateWithoutTimeout: resourceUserUpdate, DeleteWithoutTimeout: resourceUserDelete, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "email": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "iam_arn": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "identity_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - quicksight.IdentityTypeIam, - quicksight.IdentityTypeQuicksight, - }, false), - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: DefaultUserNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - - "session_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "user_name": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, - - "user_role": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - quicksight.UserRoleReader, - quicksight.UserRoleAuthor, - quicksight.UserRoleAdmin, - }, false), - }, - } + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "iam_arn": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "identity_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + quicksight.IdentityTypeIam, + quicksight.IdentityTypeQuicksight, + }, false), + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: DefaultUserNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + + "session_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "user_name": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, + + "user_role": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + quicksight.UserRoleReader, + quicksight.UserRoleAuthor, + quicksight.UserRoleAdmin, + }, false), + }, }, } } diff --git a/internal/service/quicksight/user_data_source.go b/internal/service/quicksight/user_data_source.go index a0bcd63bad35..5e987f74fc9c 100644 --- a/internal/service/quicksight/user_data_source.go +++ b/internal/service/quicksight/user_data_source.go @@ -20,51 +20,49 @@ func DataSourceUser() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceUserRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "active": { - Type: schema.TypeBool, - Computed: true, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "email": { - Type: schema.TypeString, - Computed: true, - }, - "identity_type": { - Type: schema.TypeString, - Computed: true, - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - Default: DefaultUserNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - "principal_id": { - Type: schema.TypeString, - Computed: true, - }, - "user_name": { - Type: schema.TypeString, - Required: true, - }, - "user_role": { - Type: schema.TypeString, - Computed: true, - }, - } + Schema: map[string]*schema.Schema{ + "active": { + Type: schema.TypeBool, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "email": { + Type: schema.TypeString, + Computed: true, + }, + "identity_type": { + Type: schema.TypeString, + Computed: true, + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + Default: DefaultUserNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, + "user_name": { + Type: schema.TypeString, + Required: true, + }, + "user_role": { + Type: schema.TypeString, + Computed: true, + }, }, } } From 6b0e91194e64aa618cc1a4bb161f57de27bd620a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 09:31:21 -0400 Subject: [PATCH 07/20] Revert "wafv2: Implement 'SchemaFunc()'." This reverts commit 39fc99f17f1f35f38fd12c121f95bccf3f82daf6. --- internal/service/wafv2/ip_set.go | 118 +++++----- internal/service/wafv2/ip_set_data_source.go | 56 +++-- internal/service/wafv2/regex_pattern_set.go | 86 ++++--- .../wafv2/regex_pattern_set_data_source.go | 56 +++-- internal/service/wafv2/rule_group.go | 140 ++++++------ .../service/wafv2/rule_group_data_source.go | 38 ++- internal/service/wafv2/web_acl.go | 194 ++++++++-------- internal/service/wafv2/web_acl_association.go | 28 ++- internal/service/wafv2/web_acl_data_source.go | 38 ++- .../wafv2/web_acl_logging_configuration.go | 216 +++++++++--------- 10 files changed, 475 insertions(+), 495 deletions(-) diff --git a/internal/service/wafv2/ip_set.go b/internal/service/wafv2/ip_set.go index 8c7ae1fd9058..0e1d707656ce 100644 --- a/internal/service/wafv2/ip_set.go +++ b/internal/service/wafv2/ip_set.go @@ -52,71 +52,69 @@ func ResourceIPSet() *schema.Resource { }, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "addresses": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 10000, - Elem: &schema.Schema{Type: schema.TypeString}, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - if d.GetRawPlan().GetAttr("addresses").IsWhollyKnown() { - o, n := d.GetChange("addresses") - oldAddresses := o.(*schema.Set).List() - newAddresses := n.(*schema.Set).List() - if len(oldAddresses) == len(newAddresses) { - for _, ov := range oldAddresses { - hasAddress := false - for _, nv := range newAddresses { - if itypes.CIDRBlocksEqual(ov.(string), nv.(string)) { - hasAddress = true - break - } - } - if !hasAddress { - return false + Schema: map[string]*schema.Schema{ + "addresses": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 10000, + Elem: &schema.Schema{Type: schema.TypeString}, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if d.GetRawPlan().GetAttr("addresses").IsWhollyKnown() { + o, n := d.GetChange("addresses") + oldAddresses := o.(*schema.Set).List() + newAddresses := n.(*schema.Set).List() + if len(oldAddresses) == len(newAddresses) { + for _, ov := range oldAddresses { + hasAddress := false + for _, nv := range newAddresses { + if itypes.CIDRBlocksEqual(ov.(string), nv.(string)) { + hasAddress = true + break } } - return true + if !hasAddress { + return false + } } + return true } - return false - }, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "ip_address_version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.IPAddressVersion_Values(), false), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + } + return false }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - } + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "ip_address_version": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.IPAddressVersion_Values(), false), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/ip_set_data_source.go b/internal/service/wafv2/ip_set_data_source.go index 6d51279af4c9..bb0642590111 100644 --- a/internal/service/wafv2/ip_set_data_source.go +++ b/internal/service/wafv2/ip_set_data_source.go @@ -18,35 +18,33 @@ func DataSourceIPSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceIPSetRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "addresses": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "ip_address_version": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - } + Schema: map[string]*schema.Schema{ + "addresses": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "ip_address_version": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, }, } } diff --git a/internal/service/wafv2/regex_pattern_set.go b/internal/service/wafv2/regex_pattern_set.go index f3ed8494a070..0569eebd036e 100644 --- a/internal/service/wafv2/regex_pattern_set.go +++ b/internal/service/wafv2/regex_pattern_set.go @@ -50,53 +50,51 @@ func ResourceRegexPatternSet() *schema.Resource { }, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "regular_expression": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 10, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "regex_string": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 200), - validation.StringIsValidRegExp, - ), - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "regular_expression": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "regex_string": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 200), + validation.StringIsValidRegExp, + ), }, }, }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - } + }, + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/regex_pattern_set_data_source.go b/internal/service/wafv2/regex_pattern_set_data_source.go index f4e5534c83e8..14f9d8f055cc 100644 --- a/internal/service/wafv2/regex_pattern_set_data_source.go +++ b/internal/service/wafv2/regex_pattern_set_data_source.go @@ -17,38 +17,36 @@ func DataSourceRegexPatternSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceRegexPatternSetRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "regular_expression": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "regex_string": { - Type: schema.TypeString, - Computed: true, - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "regular_expression": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "regex_string": { + Type: schema.TypeString, + Computed: true, }, }, }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - } + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, }, } } diff --git a/internal/service/wafv2/rule_group.go b/internal/service/wafv2/rule_group.go index 200060752186..4e839aeb935f 100644 --- a/internal/service/wafv2/rule_group.go +++ b/internal/service/wafv2/rule_group.go @@ -53,82 +53,80 @@ func ResourceRuleGroup() *schema.Resource { }, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "capacity": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - ValidateFunc: validation.IntAtLeast(1), - }, - "custom_response_body": customResponseBodySchema(), - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 128), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), - ), - }, - "rule": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - "captcha": captchaConfigSchema(), - "challenge": challengeConfigSchema(), - "count": countConfigSchema(), - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "capacity": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "custom_response_body": customResponseBodySchema(), + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 128), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + ), + }, + "rule": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + "captcha": captchaConfigSchema(), + "challenge": challengeConfigSchema(), + "count": countConfigSchema(), }, }, - "captcha_config": outerCaptchaConfigSchema(), - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "priority": { - Type: schema.TypeInt, - Required: true, - }, - "rule_label": ruleLabelsSchema(), - "statement": ruleGroupRootStatementSchema(ruleGroupRootStatementSchemaLevel), - "visibility_config": visibilityConfigSchema(), }, + "captcha_config": outerCaptchaConfigSchema(), + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "priority": { + Type: schema.TypeInt, + Required: true, + }, + "rule_label": ruleLabelsSchema(), + "statement": ruleGroupRootStatementSchema(ruleGroupRootStatementSchemaLevel), + "visibility_config": visibilityConfigSchema(), }, }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "visibility_config": visibilityConfigSchema(), - } + }, + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "visibility_config": visibilityConfigSchema(), }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/rule_group_data_source.go b/internal/service/wafv2/rule_group_data_source.go index 70d8d6d16ea0..615ef6939e33 100644 --- a/internal/service/wafv2/rule_group_data_source.go +++ b/internal/service/wafv2/rule_group_data_source.go @@ -17,26 +17,24 @@ func DataSourceRuleGroup() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceRuleGroupRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - } + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, }, } } diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index b3106d347a44..f6d8adb12662 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -54,114 +54,112 @@ func ResourceWebACL() *schema.Resource { }, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "capacity": { - Type: schema.TypeInt, - Computed: true, - }, - "captcha_config": outerCaptchaConfigSchema(), - "custom_response_body": customResponseBodySchema(), - "default_action": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - }, + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "capacity": { + Type: schema.TypeInt, + Computed: true, + }, + "captcha_config": outerCaptchaConfigSchema(), + "custom_response_body": customResponseBodySchema(), + "default_action": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), }, }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 128), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), - ), - }, - "rule": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - "captcha": captchaConfigSchema(), - "challenge": challengeConfigSchema(), - "count": countConfigSchema(), - }, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 128), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + ), + }, + "rule": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + "captcha": captchaConfigSchema(), + "challenge": challengeConfigSchema(), + "count": countConfigSchema(), }, }, - "captcha_config": outerCaptchaConfigSchema(), - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "override_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "count": emptySchema(), - "none": emptySchema(), - }, + }, + "captcha_config": outerCaptchaConfigSchema(), + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "override_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "count": emptySchema(), + "none": emptySchema(), }, }, - "priority": { - Type: schema.TypeInt, - Required: true, - }, - "rule_label": ruleLabelsSchema(), - "statement": webACLRootStatementSchema(webACLRootStatementSchemaLevel), - "visibility_config": visibilityConfigSchema(), }, + "priority": { + Type: schema.TypeInt, + Required: true, + }, + "rule_label": ruleLabelsSchema(), + "statement": webACLRootStatementSchema(webACLRootStatementSchemaLevel), + "visibility_config": visibilityConfigSchema(), }, }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "token_domains": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 253), - validation.StringMatch(regexp.MustCompile(`^[\w\.\-/]+$`), "must contain only alphanumeric, hyphen, dot, underscore and forward-slash characters"), - ), - }, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "token_domains": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 253), + validation.StringMatch(regexp.MustCompile(`^[\w\.\-/]+$`), "must contain only alphanumeric, hyphen, dot, underscore and forward-slash characters"), + ), }, - "visibility_config": visibilityConfigSchema(), - } + }, + "visibility_config": visibilityConfigSchema(), }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/web_acl_association.go b/internal/service/wafv2/web_acl_association.go index 0b1c51576e9d..669a51575526 100644 --- a/internal/service/wafv2/web_acl_association.go +++ b/internal/service/wafv2/web_acl_association.go @@ -33,21 +33,19 @@ func ResourceWebACLAssociation() *schema.Resource { Create: schema.DefaultTimeout(5 * time.Minute), }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "resource_arn": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "web_acl_arn": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - ValidateFunc: verify.ValidARN, - }, - } + Schema: map[string]*schema.Schema{ + "resource_arn": { + Type: schema.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "web_acl_arn": { + Type: schema.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: verify.ValidARN, + }, }, } } diff --git a/internal/service/wafv2/web_acl_data_source.go b/internal/service/wafv2/web_acl_data_source.go index 18cb2a08d111..caaf5fbbb03d 100644 --- a/internal/service/wafv2/web_acl_data_source.go +++ b/internal/service/wafv2/web_acl_data_source.go @@ -17,26 +17,24 @@ func DataSourceWebACL() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceWebACLRead, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - } + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, }, } } diff --git a/internal/service/wafv2/web_acl_logging_configuration.go b/internal/service/wafv2/web_acl_logging_configuration.go index 3e9d64500689..6d1a25f8d0c3 100644 --- a/internal/service/wafv2/web_acl_logging_configuration.go +++ b/internal/service/wafv2/web_acl_logging_configuration.go @@ -34,137 +34,135 @@ func ResourceWebACLLoggingConfiguration() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - SchemaFunc: func() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "log_destination_configs": { - Type: schema.TypeSet, - Required: true, - ForceNew: true, - MinItems: 1, - MaxItems: 100, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidARN, - }, - Description: "AWS Kinesis Firehose Delivery Stream ARNs", + Schema: map[string]*schema.Schema{ + "log_destination_configs": { + Type: schema.TypeSet, + Required: true, + ForceNew: true, + MinItems: 1, + MaxItems: 100, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: verify.ValidARN, }, - "logging_filter": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "default_behavior": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), - }, - "filter": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "behavior": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), - }, - "condition": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.ActionValue_Values(), false), - }, + Description: "AWS Kinesis Firehose Delivery Stream ARNs", + }, + "logging_filter": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "default_behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), + }, + "filter": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), + }, + "condition": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.ActionValue_Values(), false), }, }, }, - "label_name_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "label_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 1024), - validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z_\-:]+$`), "must contain only alphanumeric characters, underscores, hyphens, and colons"), - ), - }, + }, + "label_name_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "label_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 1024), + validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z_\-:]+$`), "must contain only alphanumeric characters, underscores, hyphens, and colons"), + ), }, }, }, }, }, }, - "requirement": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterRequirement_Values(), false), - }, + }, + "requirement": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterRequirement_Values(), false), }, }, }, }, }, }, - "redacted_fields": { - // To allow this argument and its nested fields with Empty Schemas (e.g. "method") - // to be correctly interpreted, this argument must be of type List, - // otherwise, at apply-time a field configured as an empty block - // (e.g. body {}) will result in a nil redacted_fields attribute - Type: schema.TypeList, - Optional: true, - MaxItems: 100, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "method": emptySchema(), - "query_string": emptySchema(), - "single_header": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 40), - // The value is returned in lower case by the API. - // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. - validation.StringMatch(regexp.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), - ), - }, + }, + "redacted_fields": { + // To allow this argument and its nested fields with Empty Schemas (e.g. "method") + // to be correctly interpreted, this argument must be of type List, + // otherwise, at apply-time a field configured as an empty block + // (e.g. body {}) will result in a nil redacted_fields attribute + Type: schema.TypeList, + Optional: true, + MaxItems: 100, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "method": emptySchema(), + "query_string": emptySchema(), + "single_header": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 40), + // The value is returned in lower case by the API. + // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. + validation.StringMatch(regexp.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), + ), }, }, }, - "uri_path": emptySchema(), }, + "uri_path": emptySchema(), }, - Description: "Parts of the request to exclude from logs", - DiffSuppressFunc: suppressRedactedFieldsDiff, }, - "resource_arn": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidARN, - Description: "AWS WebACL ARN", - }, - } + Description: "Parts of the request to exclude from logs", + DiffSuppressFunc: suppressRedactedFieldsDiff, + }, + "resource_arn": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: verify.ValidARN, + Description: "AWS WebACL ARN", + }, }, } } From 4168ced8097afffeb6acce6cfc08be7bfed6803e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 11:52:46 -0400 Subject: [PATCH 08/20] Revert "Revert "quicksight: Implement 'SchemaFunc()'."" This reverts commit 59cb145e210d112b6939208fd45f54ca4e96dad1. --- .../quicksight/account_subscription.go | 182 ++-- internal/service/quicksight/analysis.go | 153 +-- internal/service/quicksight/dashboard.go | 163 +-- internal/service/quicksight/data_set.go | 547 +++++----- .../quicksight/data_set_data_source.go | 362 +++---- internal/service/quicksight/data_source.go | 955 +++++++++--------- internal/service/quicksight/group.go | 70 +- .../service/quicksight/group_data_source.go | 64 +- .../service/quicksight/group_membership.go | 70 +- internal/service/quicksight/template.go | 143 +-- internal/service/quicksight/theme.go | 505 ++++----- .../service/quicksight/theme_data_source.go | 420 ++++---- internal/service/quicksight/user.go | 138 +-- .../service/quicksight/user_data_source.go | 88 +- 14 files changed, 1947 insertions(+), 1913 deletions(-) diff --git a/internal/service/quicksight/account_subscription.go b/internal/service/quicksight/account_subscription.go index 0daa71db9754..38aa424f1196 100644 --- a/internal/service/quicksight/account_subscription.go +++ b/internal/service/quicksight/account_subscription.go @@ -35,96 +35,98 @@ func ResourceAccountSubscription() *schema.Resource { Delete: schema.DefaultTimeout(10 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "account_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "account_subscription_status": { - Type: schema.TypeString, - Computed: true, - }, - "active_directory_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "admin_group": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - ForceNew: true, - }, - "authentication_method": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.AuthenticationMethodOption_Values(), false), - }, - "author_group": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - ForceNew: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "contact_number": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "directory_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "edition": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.Edition_Values(), false), - }, - "email_address": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "first_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "last_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - "notification_email": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "reader_group": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "realm": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "account_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "account_subscription_status": { + Type: schema.TypeString, + Computed: true, + }, + "active_directory_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "admin_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + "authentication_method": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.AuthenticationMethodOption_Values(), false), + }, + "author_group": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "contact_number": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "directory_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "edition": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.Edition_Values(), false), + }, + "email_address": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "first_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "last_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "notification_email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "reader_group": { + Type: schema.TypeList, + Optional: true, + ForceNew: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "realm": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + } }, } } diff --git a/internal/service/quicksight/analysis.go b/internal/service/quicksight/analysis.go index 15c7d3d1879d..68a2fcc4cfc9 100644 --- a/internal/service/quicksight/analysis.go +++ b/internal/service/quicksight/analysis.go @@ -51,85 +51,88 @@ func ResourceAnalysis() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "analysis_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "definition": quicksightschema.AnalysisDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "last_published_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "parameters": quicksightschema.ParametersSchema(), - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "analysis_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "definition": quicksightschema.AnalysisDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_published_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "parameters": quicksightschema.ParametersSchema(), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "recovery_window_in_days": { - Type: schema.TypeInt, - Optional: true, - Default: 30, - ValidateFunc: validation.Any( - validation.IntBetween(recoveryWindowInDaysMin, recoveryWindowInDaysMax), - validation.IntInSlice([]int{0}), - ), - }, - "source_entity": quicksightschema.AnalysisSourceEntitySchema(), - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "theme_arn": { - Type: schema.TypeString, - Optional: true, - }, + "recovery_window_in_days": { + Type: schema.TypeInt, + Optional: true, + Default: 30, + ValidateFunc: validation.Any( + validation.IntBetween(recoveryWindowInDaysMin, recoveryWindowInDaysMax), + validation.IntInSlice([]int{0}), + ), + }, + "source_entity": quicksightschema.AnalysisSourceEntitySchema(), + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "theme_arn": { + Type: schema.TypeString, + Optional: true, + }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/dashboard.go b/internal/service/quicksight/dashboard.go index b7d569e06283..418ff5879d40 100644 --- a/internal/service/quicksight/dashboard.go +++ b/internal/service/quicksight/dashboard.go @@ -44,90 +44,93 @@ func ResourceDashboard() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "dashboard_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "dashboard_publish_options": quicksightschema.DashboardPublishOptionsSchema(), - "definition": quicksightschema.DashboardDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "last_published_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "parameters": quicksightschema.ParametersSchema(), - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "dashboard_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "dashboard_publish_options": quicksightschema.DashboardPublishOptionsSchema(), + "definition": quicksightschema.DashboardDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "last_published_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "parameters": quicksightschema.ParametersSchema(), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "source_entity": quicksightschema.DashboardSourceEntitySchema(), - "source_entity_arn": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "theme_arn": { - Type: schema.TypeString, - Optional: true, - }, - "version_description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "source_entity": quicksightschema.DashboardSourceEntitySchema(), + "source_entity_arn": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "theme_arn": { + Type: schema.TypeString, + Optional: true, + }, + "version_description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, + CustomizeDiff: customdiff.All( refreshOutputsDiff, verify.SetTagsDiff, diff --git a/internal/service/quicksight/data_set.go b/internal/service/quicksight/data_set.go index ff475f777cd8..d8c36e769971 100644 --- a/internal/service/quicksight/data_set.go +++ b/internal/service/quicksight/data_set.go @@ -35,307 +35,309 @@ func ResourceDataSet() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "column_groups": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 8, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "geo_spatial_column_group": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "columns": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{ + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "column_groups": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 8, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "geo_spatial_column_group": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "columns": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + }, + "country_code": { Type: schema.TypeString, - ValidateFunc: validation.StringLenBetween(1, 128), + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.GeoSpatialCountryCode_Values(), false), + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 64), }, - }, - "country_code": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.GeoSpatialCountryCode_Values(), false), - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 64), }, }, }, }, }, }, - }, - "column_level_permission_rules": { - Type: schema.TypeList, - MinItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_names": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principals": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 100, - Elem: &schema.Schema{Type: schema.TypeString}, + "column_level_permission_rules": { + Type: schema.TypeList, + MinItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_names": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principals": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 100, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, }, }, - }, - "data_set_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "data_set_usage_configuration": { - Type: schema.TypeList, - Computed: true, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_use_as_direct_query_source": { - Type: schema.TypeBool, - Computed: true, - Optional: true, - }, - "disable_use_as_imported_source": { - Type: schema.TypeBool, - Computed: true, - Optional: true, + "data_set_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "data_set_usage_configuration": { + Type: schema.TypeList, + Computed: true, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_use_as_direct_query_source": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + }, + "disable_use_as_imported_source": { + Type: schema.TypeBool, + Computed: true, + Optional: true, + }, }, }, }, - }, - "field_folders": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 1000, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "field_folders_id": { - Type: schema.TypeString, - Required: true, - }, - "columns": { - Type: schema.TypeList, - Optional: true, - MaxItems: 5000, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 500), + "field_folders": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 1000, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_folders_id": { + Type: schema.TypeString, + Required: true, + }, + "columns": { + Type: schema.TypeList, + Optional: true, + MaxItems: 5000, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 500), + }, }, }, }, - }, - "import_mode": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.DataSetImportMode_Values(), false), - }, - "logical_table_map": { - Type: schema.TypeSet, - Optional: true, - Computed: true, - MaxItems: 64, - Elem: logicalTableMapSchema(), - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "output_columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "type": { - Type: schema.TypeString, - Computed: true, + "import_mode": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.DataSetImportMode_Values(), false), + }, + "logical_table_map": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + MaxItems: 64, + Elem: logicalTableMapSchema(), + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "output_columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "physical_table_map": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 32, - Elem: physicalTableMapSchema(), - }, - "row_level_permission_data_set": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "format_version": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionFormatVersion_Values(), false), - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 64), - }, - "permission_policy": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionPolicy_Values(), false), - }, - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + "physical_table_map": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 32, + Elem: physicalTableMapSchema(), + }, + "row_level_permission_data_set": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "format_version": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionFormatVersion_Values(), false), + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(0, 64), + }, + "permission_policy": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.RowLevelPermissionPolicy_Values(), false), + }, + "status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + }, }, }, }, - }, - "row_level_permission_tag_configuration": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), - }, - "tag_rules": { - Type: schema.TypeList, - Required: true, - MinItems: 1, - MaxItems: 50, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "match_all_value": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "tag_key": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "tag_multi_value_delimiter": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 10), + "row_level_permission_tag_configuration": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(quicksight.Status_Values(), false), + }, + "tag_rules": { + Type: schema.TypeList, + Required: true, + MinItems: 1, + MaxItems: 50, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "match_all_value": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "tag_key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "tag_multi_value_delimiter": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 10), + }, }, }, }, }, }, }, - }, - "refresh_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "refresh_configuration": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "incremental_refresh": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "lookback_window": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Required: true, - }, - "size": { - Type: schema.TypeInt, - Required: true, - }, - "size_unit": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(quicksight.LookbackWindowSizeUnit_Values(), false), + "refresh_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "refresh_configuration": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "incremental_refresh": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "lookback_window": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Required: true, + }, + "size": { + Type: schema.TypeInt, + Required: true, + }, + "size_unit": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(quicksight.LookbackWindowSizeUnit_Values(), false), + }, }, }, }, @@ -348,10 +350,11 @@ func ResourceDataSet() *schema.Resource { }, }, }, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, + CustomizeDiff: customdiff.All( func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error { mode := diff.Get("import_mode").(string) diff --git a/internal/service/quicksight/data_set_data_source.go b/internal/service/quicksight/data_set_data_source.go index 24883a7ebf79..2c9fd925dac8 100644 --- a/internal/service/quicksight/data_set_data_source.go +++ b/internal/service/quicksight/data_set_data_source.go @@ -19,214 +19,216 @@ func DataSourceDataSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceDataSetRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidAccountID, - }, - "column_groups": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "geo_spatial_column_group": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: verify.ValidAccountID, + }, + "column_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "geo_spatial_column_group": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "country_code": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, }, - }, - "country_code": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, }, }, }, }, }, }, - }, - "column_level_permission_rules": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_names": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principals": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, + "column_level_permission_rules": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principals": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, }, }, - }, - "data_set_id": { - Type: schema.TypeString, - Required: true, - }, - "data_set_usage_configuration": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_use_as_direct_query_source": { - Type: schema.TypeBool, - Computed: true, - }, - "disable_use_as_imported_source": { - Type: schema.TypeBool, - Computed: true, + "data_set_id": { + Type: schema.TypeString, + Required: true, + }, + "data_set_usage_configuration": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_use_as_direct_query_source": { + Type: schema.TypeBool, + Computed: true, + }, + "disable_use_as_imported_source": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, - }, - "field_folders": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "field_folders_id": { - Type: schema.TypeString, - Computed: true, - }, - "columns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "description": { - Type: schema.TypeString, - Computed: true, + "field_folders": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "field_folders_id": { + Type: schema.TypeString, + Computed: true, + }, + "columns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "import_mode": { - Type: schema.TypeString, - Computed: true, - }, - "logical_table_map": { - Type: schema.TypeSet, - Computed: true, - Elem: logicalTableMapDataSourceSchema(), - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "permissions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Computed: true, + "import_mode": { + Type: schema.TypeString, + Computed: true, + }, + "logical_table_map": { + Type: schema.TypeSet, + Computed: true, + Elem: logicalTableMapDataSourceSchema(), + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "permissions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "physical_table_map": { - Type: schema.TypeSet, - Computed: true, - Elem: physicalTableMapDataSourceSchema(), - }, - "row_level_permission_data_set": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "format_version": { - Type: schema.TypeString, - Computed: true, - }, - "namespace": { - Type: schema.TypeString, - Computed: true, - }, - "permission_policy": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, + "physical_table_map": { + Type: schema.TypeSet, + Computed: true, + Elem: physicalTableMapDataSourceSchema(), + }, + "row_level_permission_data_set": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "format_version": { + Type: schema.TypeString, + Computed: true, + }, + "namespace": { + Type: schema.TypeString, + Computed: true, + }, + "permission_policy": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "row_level_permission_tag_configuration": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "status": { - Type: schema.TypeString, - Computed: true, - }, - "tag_rules": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_name": { - Type: schema.TypeString, - Computed: true, - }, - "match_all_value": { - Type: schema.TypeString, - Computed: true, - }, - "tag_key": { - Type: schema.TypeString, - Computed: true, - }, - "tag_multi_value_delimiter": { - Type: schema.TypeString, - Computed: true, + "row_level_permission_tag_configuration": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "status": { + Type: schema.TypeString, + Computed: true, + }, + "tag_rules": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "column_name": { + Type: schema.TypeString, + Computed: true, + }, + "match_all_value": { + Type: schema.TypeString, + Computed: true, + }, + "tag_key": { + Type: schema.TypeString, + Computed: true, + }, + "tag_multi_value_delimiter": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "tags": tftags.TagsSchemaComputed(), - "tags_all": { - Type: schema.TypeMap, - Optional: true, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Deprecated: `this attribute has been deprecated`, - }, + "tags": tftags.TagsSchemaComputed(), + "tags_all": { + Type: schema.TypeMap, + Optional: true, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Deprecated: `this attribute has been deprecated`, + }, + } }, } } diff --git a/internal/service/quicksight/data_source.go b/internal/service/quicksight/data_source.go index 1a2c6f5d1c5f..3c0f28217319 100644 --- a/internal/service/quicksight/data_source.go +++ b/internal/service/quicksight/data_source.go @@ -31,574 +31,577 @@ func ResourceDataSource() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, - "credentials": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "copy_source_arn": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidARN, - ConflictsWith: []string{"credentials.0.credential_pair"}, - }, - "credential_pair": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "password": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 1024), - ), - Sensitive: true, - }, - "username": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 64), - ), - Sensitive: true, + "credentials": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "copy_source_arn": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: verify.ValidARN, + ConflictsWith: []string{"credentials.0.credential_pair"}, + }, + "credential_pair": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "password": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 1024), + ), + Sensitive: true, + }, + "username": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 64), + ), + Sensitive: true, + }, }, }, + ConflictsWith: []string{"credentials.0.copy_source_arn"}, }, - ConflictsWith: []string{"credentials.0.copy_source_arn"}, }, }, }, - }, - "data_source_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, + "data_source_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.NoZeroValues, - validation.StringLenBetween(1, 128), - ), - }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.NoZeroValues, + validation.StringLenBetween(1, 128), + ), + }, - "parameters": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "amazon_elasticsearch": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "domain": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "parameters": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "amazon_elasticsearch": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "domain": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "athena": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "work_group": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, + "athena": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "work_group": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "aurora": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "aurora": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "aurora_postgresql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "aurora_postgresql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "aws_iot_analytics": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_set_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "aws_iot_analytics": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_set_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "jira": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "site_base_url": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "jira": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "site_base_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "maria_db": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "maria_db": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "mysql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "mysql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "oracle": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "oracle": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "postgresql": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "postgresql": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "presto": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "catalog": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "presto": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "catalog": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "rds": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "instance_id": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "rds": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "instance_id": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "redshift": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cluster_id": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Optional: true, - }, - "port": { - Type: schema.TypeInt, - Optional: true, + "redshift": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cluster_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Optional: true, + }, + "port": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "s3": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "manifest_file_location": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "bucket": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "key": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "s3": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "manifest_file_location": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bucket": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "key": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, }, }, }, - }, - "service_now": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "site_base_url": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "service_now": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "site_base_url": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "snowflake": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "warehouse": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "snowflake": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "warehouse": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, - }, - "spark": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "spark": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "sql_server": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "sql_server": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "teradata": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "host": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, - }, - "port": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), + "teradata": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "database": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "host": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, }, }, }, - }, - "twitter": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "max_rows": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.IntAtLeast(1), - }, - "query": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.NoZeroValues, + "twitter": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "max_rows": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "query": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.NoZeroValues, + }, }, }, }, }, }, }, - }, - "permission": { - Type: schema.TypeSet, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - MinItems: 1, - MaxItems: 16, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, + "permission": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + MinItems: 1, + MaxItems: 16, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, }, }, }, - }, - "ssl_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disable_ssl": { - Type: schema.TypeBool, - Required: true, + "ssl_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "disable_ssl": { + Type: schema.TypeBool, + Required: true, + }, }, }, }, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), - "type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(quicksight.DataSourceType_Values(), false), - }, + "type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(quicksight.DataSourceType_Values(), false), + }, - "vpc_connection_properties": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "vpc_connection_arn": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidARN, + "vpc_connection_properties": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "vpc_connection_arn": { + Type: schema.TypeString, + Required: true, + ValidateFunc: verify.ValidARN, + }, }, }, }, - }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/group.go b/internal/service/quicksight/group.go index 06000416a678..0911b6a822f2 100644 --- a/internal/service/quicksight/group.go +++ b/internal/service/quicksight/group.go @@ -33,40 +33,42 @@ func ResourceGroup() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "description": { - Type: schema.TypeString, - Optional: true, - }, - - "group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: DefaultGroupNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "description": { + Type: schema.TypeString, + Optional: true, + }, + + "group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: DefaultGroupNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + } }, } } diff --git a/internal/service/quicksight/group_data_source.go b/internal/service/quicksight/group_data_source.go index 20a91847c3aa..0a5438608735 100644 --- a/internal/service/quicksight/group_data_source.go +++ b/internal/service/quicksight/group_data_source.go @@ -20,37 +20,39 @@ func DataSourceGroup() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceGroupRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "group_name": { - Type: schema.TypeString, - Required: true, - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - Default: DefaultGroupNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - "principal_id": { - Type: schema.TypeString, - Computed: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "group_name": { + Type: schema.TypeString, + Required: true, + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + Default: DefaultGroupNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, + } }, } } diff --git a/internal/service/quicksight/group_membership.go b/internal/service/quicksight/group_membership.go index 584559505b85..ba31ca9e5f65 100644 --- a/internal/service/quicksight/group_membership.go +++ b/internal/service/quicksight/group_membership.go @@ -26,40 +26,42 @@ func ResourceGroupMembership() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "member_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "group_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: "default", - ValidateFunc: validation.StringInSlice([]string{ - "default", - }, false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "member_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "group_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "default", + ValidateFunc: validation.StringInSlice([]string{ + "default", + }, false), + }, + } }, } } diff --git a/internal/service/quicksight/template.go b/internal/service/quicksight/template.go index 2e5227849d5d..5ca5b56d1b87 100644 --- a/internal/service/quicksight/template.go +++ b/internal/service/quicksight/template.go @@ -42,80 +42,83 @@ func ResourceTemplate() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "definition": quicksightschema.TemplateDefinitionSchema(), - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "definition": quicksightschema.TemplateDefinitionSchema(), + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "source_entity": quicksightschema.TemplateSourceEntitySchema(), - "source_entity_arn": { - Type: schema.TypeString, - Computed: true, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "template_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "version_description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "source_entity": quicksightschema.TemplateSourceEntitySchema(), + "source_entity_arn": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "template_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "version_description": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/theme.go b/internal/service/quicksight/theme.go index a8c8ad9441e1..4fd97b6f0f3d 100644 --- a/internal/service/quicksight/theme.go +++ b/internal/service/quicksight/theme.go @@ -43,118 +43,120 @@ func ResourceTheme() *schema.Resource { Delete: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - ValidateFunc: verify.ValidAccountID, - }, - "base_theme_id": { - Type: schema.TypeString, - Required: true, - }, - "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "colors": { - Type: schema.TypeList, - Optional: true, - MinItems: 8, // Colors size needs to be in the range between 8 and 20 - MaxItems: 20, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + ValidateFunc: verify.ValidAccountID, + }, + "base_theme_id": { + Type: schema.TypeString, + Required: true, + }, + "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "colors": { + Type: schema.TypeList, + Optional: true, + MinItems: 8, // Colors size needs to be in the range between 8 and 20 + MaxItems: 20, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, }, - }, - "empty_fill_color": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "min_max_gradient": { - Type: schema.TypeList, - Optional: true, - MinItems: 2, // MinMaxGradient size needs to be 2 - MaxItems: 2, - Elem: &schema.Schema{ + "empty_fill_color": { Type: schema.TypeString, + Optional: true, ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), }, + "min_max_gradient": { + Type: schema.TypeList, + Optional: true, + MinItems: 2, // MinMaxGradient size needs to be 2 + MaxItems: 2, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + }, }, }, }, - }, - "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, + "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, }, }, }, - }, - "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, + "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, - }, - "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Optional: true, + "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, @@ -164,177 +166,178 @@ func ResourceTheme() *schema.Resource { }, }, }, - }, - "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html - Type: schema.TypeList, - MaxItems: 5, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_family": { - Type: schema.TypeString, - Optional: true, + "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html + Type: schema.TypeList, + MaxItems: 5, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_family": { + Type: schema.TypeString, + Optional: true, + }, }, }, }, }, }, }, - }, - "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accent": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "accent_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "danger": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "danger_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "dimension": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "dimension_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "measure": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "measure_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "primary_background": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "primary_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "secondary_background": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "secondary_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "success": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "success_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "warning": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), - }, - "warning_foreground": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accent": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "accent_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "danger": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "danger_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "dimension": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "dimension_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "measure": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "measure_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "primary_background": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "primary_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "secondary_background": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "secondary_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "success": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "success_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "warning": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, + "warning_foreground": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^#[A-F0-9]{6}$`), ""), + }, }, }, }, }, }, }, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "theme_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 2048), - }, - "permissions": { - Type: schema.TypeList, - Optional: true, - MinItems: 1, - MaxItems: 64, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - MaxItems: 16, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 256), + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "theme_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 2048), + }, + "permissions": { + Type: schema.TypeList, + Optional: true, + MinItems: 1, + MaxItems: 64, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + MaxItems: 16, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, }, }, }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "version_description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 512), - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "version_description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 512), + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, + CustomizeDiff: verify.SetTagsDiff, } } diff --git a/internal/service/quicksight/theme_data_source.go b/internal/service/quicksight/theme_data_source.go index b0f55c3bd6bf..b4fb24895a8d 100644 --- a/internal/service/quicksight/theme_data_source.go +++ b/internal/service/quicksight/theme_data_source.go @@ -20,102 +20,104 @@ func DataSourceTheme() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceThemeRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidAccountID, - }, - "base_theme_id": { - Type: schema.TypeString, - Computed: true, - }, - "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "colors": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: verify.ValidAccountID, + }, + "base_theme_id": { + Type: schema.TypeString, + Computed: true, + }, + "configuration": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ThemeConfiguration.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "data_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DataColorPalette.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "colors": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, - }, - "empty_fill_color": { - Type: schema.TypeString, - Computed: true, - }, - "min_max_gradient": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, + "empty_fill_color": { + Type: schema.TypeString, + Computed: true, + }, + "min_max_gradient": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, }, - }, - "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, + "sheet": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_SheetStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tile": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "border": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BorderStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, }, }, }, - }, - "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, + "tile_layout": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TileLayoutStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "gutter": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_GutterStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, - }, - "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "show": { - Type: schema.TypeBool, - Computed: true, + "margin": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MarginStyle.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "show": { + Type: schema.TypeBool, + Computed: true, + }, }, }, }, @@ -125,148 +127,148 @@ func DataSourceTheme() *schema.Resource { }, }, }, - }, - "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "font_family": { - Type: schema.TypeString, - Computed: true, + "typography": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Typography.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_families": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_Font.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "font_family": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accent": { - Type: schema.TypeString, - Computed: true, - }, - "accent_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "danger": { - Type: schema.TypeString, - Computed: true, - }, - "danger_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "dimension": { - Type: schema.TypeString, - Computed: true, - }, - "dimension_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "measure": { - Type: schema.TypeString, - Computed: true, - }, - "measure_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "primary_background": { - Type: schema.TypeString, - Computed: true, - }, - "primary_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_background": { - Type: schema.TypeString, - Computed: true, - }, - "secondary_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "success": { - Type: schema.TypeString, - Computed: true, - }, - "success_foreground": { - Type: schema.TypeString, - Computed: true, - }, - "warning": { - Type: schema.TypeString, - Computed: true, - }, - "warning_foreground": { - Type: schema.TypeString, - Computed: true, + "ui_color_palette": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_UIColorPalette.html + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "accent": { + Type: schema.TypeString, + Computed: true, + }, + "accent_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "danger": { + Type: schema.TypeString, + Computed: true, + }, + "danger_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "dimension": { + Type: schema.TypeString, + Computed: true, + }, + "dimension_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "measure": { + Type: schema.TypeString, + Computed: true, + }, + "measure_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "primary_background": { + Type: schema.TypeString, + Computed: true, + }, + "primary_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_background": { + Type: schema.TypeString, + Computed: true, + }, + "secondary_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "success": { + Type: schema.TypeString, + Computed: true, + }, + "success_foreground": { + Type: schema.TypeString, + Computed: true, + }, + "warning": { + Type: schema.TypeString, + Computed: true, + }, + "warning_foreground": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "created_time": { - Type: schema.TypeString, - Computed: true, - }, - "theme_id": { - Type: schema.TypeString, - Required: true, - }, - "last_updated_time": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "permissions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "actions": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "principal": { - Type: schema.TypeString, - Computed: true, + "created_time": { + Type: schema.TypeString, + Computed: true, + }, + "theme_id": { + Type: schema.TypeString, + Required: true, + }, + "last_updated_time": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Computed: true, + }, + "permissions": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "actions": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "principal": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "status": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchemaComputed(), - "version_description": { - Type: schema.TypeString, - Computed: true, - }, - "version_number": { - Type: schema.TypeInt, - Computed: true, - }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchemaComputed(), + "version_description": { + Type: schema.TypeString, + Computed: true, + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + } }, } } diff --git a/internal/service/quicksight/user.go b/internal/service/quicksight/user.go index de7078030daf..5c1c991f818e 100644 --- a/internal/service/quicksight/user.go +++ b/internal/service/quicksight/user.go @@ -29,74 +29,76 @@ func ResourceUser() *schema.Resource { UpdateWithoutTimeout: resourceUserUpdate, DeleteWithoutTimeout: resourceUserDelete, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - - "email": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "iam_arn": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "identity_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - quicksight.IdentityTypeIam, - quicksight.IdentityTypeQuicksight, - }, false), - }, - - "namespace": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Default: DefaultUserNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - - "session_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - }, - - "user_name": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.NoZeroValues, - }, - - "user_role": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice([]string{ - quicksight.UserRoleReader, - quicksight.UserRoleAuthor, - quicksight.UserRoleAdmin, - }, false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + + "email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + + "iam_arn": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "identity_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + quicksight.IdentityTypeIam, + quicksight.IdentityTypeQuicksight, + }, false), + }, + + "namespace": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: DefaultUserNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + + "session_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + + "user_name": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.NoZeroValues, + }, + + "user_role": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + quicksight.UserRoleReader, + quicksight.UserRoleAuthor, + quicksight.UserRoleAdmin, + }, false), + }, + } }, } } diff --git a/internal/service/quicksight/user_data_source.go b/internal/service/quicksight/user_data_source.go index 5e987f74fc9c..a0bcd63bad35 100644 --- a/internal/service/quicksight/user_data_source.go +++ b/internal/service/quicksight/user_data_source.go @@ -20,49 +20,51 @@ func DataSourceUser() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceUserRead, - Schema: map[string]*schema.Schema{ - "active": { - Type: schema.TypeBool, - Computed: true, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "aws_account_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "email": { - Type: schema.TypeString, - Computed: true, - }, - "identity_type": { - Type: schema.TypeString, - Computed: true, - }, - "namespace": { - Type: schema.TypeString, - Optional: true, - Default: DefaultUserNamespace, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 63), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), - ), - }, - "principal_id": { - Type: schema.TypeString, - Computed: true, - }, - "user_name": { - Type: schema.TypeString, - Required: true, - }, - "user_role": { - Type: schema.TypeString, - Computed: true, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "active": { + Type: schema.TypeBool, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "aws_account_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "email": { + Type: schema.TypeString, + Computed: true, + }, + "identity_type": { + Type: schema.TypeString, + Computed: true, + }, + "namespace": { + Type: schema.TypeString, + Optional: true, + Default: DefaultUserNamespace, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 63), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9._-]*$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), + ), + }, + "principal_id": { + Type: schema.TypeString, + Computed: true, + }, + "user_name": { + Type: schema.TypeString, + Required: true, + }, + "user_role": { + Type: schema.TypeString, + Computed: true, + }, + } }, } } From 3d37e19ed9055724cdc98d2b2af788051434e562 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 11:52:46 -0400 Subject: [PATCH 09/20] Revert "Revert "wafv2: Implement 'SchemaFunc()'."" This reverts commit 6b0e91194e64aa618cc1a4bb161f57de27bd620a. --- internal/service/wafv2/ip_set.go | 118 +++++----- internal/service/wafv2/ip_set_data_source.go | 56 ++--- internal/service/wafv2/regex_pattern_set.go | 86 +++---- .../wafv2/regex_pattern_set_data_source.go | 56 ++--- internal/service/wafv2/rule_group.go | 140 ++++++------ .../service/wafv2/rule_group_data_source.go | 38 +-- internal/service/wafv2/web_acl.go | 194 ++++++++-------- internal/service/wafv2/web_acl_association.go | 28 +-- internal/service/wafv2/web_acl_data_source.go | 38 +-- .../wafv2/web_acl_logging_configuration.go | 216 +++++++++--------- 10 files changed, 495 insertions(+), 475 deletions(-) diff --git a/internal/service/wafv2/ip_set.go b/internal/service/wafv2/ip_set.go index 0e1d707656ce..8c7ae1fd9058 100644 --- a/internal/service/wafv2/ip_set.go +++ b/internal/service/wafv2/ip_set.go @@ -52,69 +52,71 @@ func ResourceIPSet() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "addresses": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 10000, - Elem: &schema.Schema{Type: schema.TypeString}, - DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - if d.GetRawPlan().GetAttr("addresses").IsWhollyKnown() { - o, n := d.GetChange("addresses") - oldAddresses := o.(*schema.Set).List() - newAddresses := n.(*schema.Set).List() - if len(oldAddresses) == len(newAddresses) { - for _, ov := range oldAddresses { - hasAddress := false - for _, nv := range newAddresses { - if itypes.CIDRBlocksEqual(ov.(string), nv.(string)) { - hasAddress = true - break + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "addresses": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 10000, + Elem: &schema.Schema{Type: schema.TypeString}, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if d.GetRawPlan().GetAttr("addresses").IsWhollyKnown() { + o, n := d.GetChange("addresses") + oldAddresses := o.(*schema.Set).List() + newAddresses := n.(*schema.Set).List() + if len(oldAddresses) == len(newAddresses) { + for _, ov := range oldAddresses { + hasAddress := false + for _, nv := range newAddresses { + if itypes.CIDRBlocksEqual(ov.(string), nv.(string)) { + hasAddress = true + break + } + } + if !hasAddress { + return false } } - if !hasAddress { - return false - } + return true } - return true } - } - return false + return false + }, }, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "ip_address_version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.IPAddressVersion_Values(), false), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "ip_address_version": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.IPAddressVersion_Values(), false), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/ip_set_data_source.go b/internal/service/wafv2/ip_set_data_source.go index bb0642590111..6d51279af4c9 100644 --- a/internal/service/wafv2/ip_set_data_source.go +++ b/internal/service/wafv2/ip_set_data_source.go @@ -18,33 +18,35 @@ func DataSourceIPSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceIPSetRead, - Schema: map[string]*schema.Schema{ - "addresses": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "ip_address_version": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "addresses": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "ip_address_version": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/regex_pattern_set.go b/internal/service/wafv2/regex_pattern_set.go index 0569eebd036e..f3ed8494a070 100644 --- a/internal/service/wafv2/regex_pattern_set.go +++ b/internal/service/wafv2/regex_pattern_set.go @@ -50,51 +50,53 @@ func ResourceRegexPatternSet() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "regular_expression": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 10, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "regex_string": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 200), - validation.StringIsValidRegExp, - ), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "regular_expression": { + Type: schema.TypeSet, + Optional: true, + MaxItems: 10, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "regex_string": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 200), + validation.StringIsValidRegExp, + ), + }, }, }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/regex_pattern_set_data_source.go b/internal/service/wafv2/regex_pattern_set_data_source.go index 14f9d8f055cc..f4e5534c83e8 100644 --- a/internal/service/wafv2/regex_pattern_set_data_source.go +++ b/internal/service/wafv2/regex_pattern_set_data_source.go @@ -17,36 +17,38 @@ func DataSourceRegexPatternSet() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceRegexPatternSetRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "regular_expression": { - Type: schema.TypeSet, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "regex_string": { - Type: schema.TypeString, - Computed: true, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "regular_expression": { + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "regex_string": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/rule_group.go b/internal/service/wafv2/rule_group.go index 4e839aeb935f..200060752186 100644 --- a/internal/service/wafv2/rule_group.go +++ b/internal/service/wafv2/rule_group.go @@ -53,80 +53,82 @@ func ResourceRuleGroup() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "capacity": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - ValidateFunc: validation.IntAtLeast(1), - }, - "custom_response_body": customResponseBodySchema(), - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 128), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), - ), - }, - "rule": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - "captcha": captchaConfigSchema(), - "challenge": challengeConfigSchema(), - "count": countConfigSchema(), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "capacity": { + Type: schema.TypeInt, + Required: true, + ForceNew: true, + ValidateFunc: validation.IntAtLeast(1), + }, + "custom_response_body": customResponseBodySchema(), + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 128), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + ), + }, + "rule": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + "captcha": captchaConfigSchema(), + "challenge": challengeConfigSchema(), + "count": countConfigSchema(), + }, }, }, + "captcha_config": outerCaptchaConfigSchema(), + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "priority": { + Type: schema.TypeInt, + Required: true, + }, + "rule_label": ruleLabelsSchema(), + "statement": ruleGroupRootStatementSchema(ruleGroupRootStatementSchemaLevel), + "visibility_config": visibilityConfigSchema(), }, - "captcha_config": outerCaptchaConfigSchema(), - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "priority": { - Type: schema.TypeInt, - Required: true, - }, - "rule_label": ruleLabelsSchema(), - "statement": ruleGroupRootStatementSchema(ruleGroupRootStatementSchemaLevel), - "visibility_config": visibilityConfigSchema(), }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "visibility_config": visibilityConfigSchema(), + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "visibility_config": visibilityConfigSchema(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/rule_group_data_source.go b/internal/service/wafv2/rule_group_data_source.go index 615ef6939e33..70d8d6d16ea0 100644 --- a/internal/service/wafv2/rule_group_data_source.go +++ b/internal/service/wafv2/rule_group_data_source.go @@ -17,24 +17,26 @@ func DataSourceRuleGroup() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceRuleGroupRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index f6d8adb12662..b3106d347a44 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -54,112 +54,114 @@ func ResourceWebACL() *schema.Resource { }, }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "capacity": { - Type: schema.TypeInt, - Computed: true, - }, - "captcha_config": outerCaptchaConfigSchema(), - "custom_response_body": customResponseBodySchema(), - "default_action": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "capacity": { + Type: schema.TypeInt, + Computed: true, + }, + "captcha_config": outerCaptchaConfigSchema(), + "custom_response_body": customResponseBodySchema(), + "default_action": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + }, }, }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(1, 256), - }, - "lock_token": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 128), - validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), - ), - }, - "rule": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow": allowConfigSchema(), - "block": blockConfigSchema(), - "captcha": captchaConfigSchema(), - "challenge": challengeConfigSchema(), - "count": countConfigSchema(), + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 256), + }, + "lock_token": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 128), + validation.StringMatch(regexp.MustCompile(`^[a-zA-Z0-9-_]+$`), "must contain only alphanumeric hyphen and underscore characters"), + ), + }, + "rule": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow": allowConfigSchema(), + "block": blockConfigSchema(), + "captcha": captchaConfigSchema(), + "challenge": challengeConfigSchema(), + "count": countConfigSchema(), + }, }, }, - }, - "captcha_config": outerCaptchaConfigSchema(), - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringLenBetween(1, 128), - }, - "override_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "count": emptySchema(), - "none": emptySchema(), + "captcha_config": outerCaptchaConfigSchema(), + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringLenBetween(1, 128), + }, + "override_action": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "count": emptySchema(), + "none": emptySchema(), + }, }, }, + "priority": { + Type: schema.TypeInt, + Required: true, + }, + "rule_label": ruleLabelsSchema(), + "statement": webACLRootStatementSchema(webACLRootStatementSchemaLevel), + "visibility_config": visibilityConfigSchema(), }, - "priority": { - Type: schema.TypeInt, - Required: true, - }, - "rule_label": ruleLabelsSchema(), - "statement": webACLRootStatementSchema(webACLRootStatementSchemaLevel), - "visibility_config": visibilityConfigSchema(), }, }, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "token_domains": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 253), - validation.StringMatch(regexp.MustCompile(`^[\w\.\-/]+$`), "must contain only alphanumeric, hyphen, dot, underscore and forward-slash characters"), - ), + "scope": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), }, - }, - "visibility_config": visibilityConfigSchema(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "token_domains": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 253), + validation.StringMatch(regexp.MustCompile(`^[\w\.\-/]+$`), "must contain only alphanumeric, hyphen, dot, underscore and forward-slash characters"), + ), + }, + }, + "visibility_config": visibilityConfigSchema(), + } }, CustomizeDiff: verify.SetTagsDiff, diff --git a/internal/service/wafv2/web_acl_association.go b/internal/service/wafv2/web_acl_association.go index 669a51575526..0b1c51576e9d 100644 --- a/internal/service/wafv2/web_acl_association.go +++ b/internal/service/wafv2/web_acl_association.go @@ -33,19 +33,21 @@ func ResourceWebACLAssociation() *schema.Resource { Create: schema.DefaultTimeout(5 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "resource_arn": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - ValidateFunc: verify.ValidARN, - }, - "web_acl_arn": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - ValidateFunc: verify.ValidARN, - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "resource_arn": { + Type: schema.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: verify.ValidARN, + }, + "web_acl_arn": { + Type: schema.TypeString, + ForceNew: true, + Required: true, + ValidateFunc: verify.ValidARN, + }, + } }, } } diff --git a/internal/service/wafv2/web_acl_data_source.go b/internal/service/wafv2/web_acl_data_source.go index caaf5fbbb03d..18cb2a08d111 100644 --- a/internal/service/wafv2/web_acl_data_source.go +++ b/internal/service/wafv2/web_acl_data_source.go @@ -17,24 +17,26 @@ func DataSourceWebACL() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceWebACLRead, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "scope": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), - }, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "description": { + Type: schema.TypeString, + Computed: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "scope": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.Scope_Values(), false), + }, + } }, } } diff --git a/internal/service/wafv2/web_acl_logging_configuration.go b/internal/service/wafv2/web_acl_logging_configuration.go index 6d1a25f8d0c3..3e9d64500689 100644 --- a/internal/service/wafv2/web_acl_logging_configuration.go +++ b/internal/service/wafv2/web_acl_logging_configuration.go @@ -34,135 +34,137 @@ func ResourceWebACLLoggingConfiguration() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "log_destination_configs": { - Type: schema.TypeSet, - Required: true, - ForceNew: true, - MinItems: 1, - MaxItems: 100, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidARN, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "log_destination_configs": { + Type: schema.TypeSet, + Required: true, + ForceNew: true, + MinItems: 1, + MaxItems: 100, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: verify.ValidARN, + }, + Description: "AWS Kinesis Firehose Delivery Stream ARNs", }, - Description: "AWS Kinesis Firehose Delivery Stream ARNs", - }, - "logging_filter": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "default_behavior": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), - }, - "filter": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "behavior": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), - }, - "condition": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.ActionValue_Values(), false), + "logging_filter": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "default_behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), + }, + "filter": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "behavior": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterBehavior_Values(), false), + }, + "condition": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "action": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.ActionValue_Values(), false), + }, }, }, }, - }, - "label_name_condition": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "label_name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 1024), - validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z_\-:]+$`), "must contain only alphanumeric characters, underscores, hyphens, and colons"), - ), + "label_name_condition": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "label_name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 1024), + validation.StringMatch(regexp.MustCompile(`^[0-9A-Za-z_\-:]+$`), "must contain only alphanumeric characters, underscores, hyphens, and colons"), + ), + }, }, }, }, }, }, }, - }, - "requirement": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(wafv2.FilterRequirement_Values(), false), + "requirement": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(wafv2.FilterRequirement_Values(), false), + }, }, }, }, }, }, }, - }, - "redacted_fields": { - // To allow this argument and its nested fields with Empty Schemas (e.g. "method") - // to be correctly interpreted, this argument must be of type List, - // otherwise, at apply-time a field configured as an empty block - // (e.g. body {}) will result in a nil redacted_fields attribute - Type: schema.TypeList, - Optional: true, - MaxItems: 100, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "method": emptySchema(), - "query_string": emptySchema(), - "single_header": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 40), - // The value is returned in lower case by the API. - // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. - validation.StringMatch(regexp.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), - ), + "redacted_fields": { + // To allow this argument and its nested fields with Empty Schemas (e.g. "method") + // to be correctly interpreted, this argument must be of type List, + // otherwise, at apply-time a field configured as an empty block + // (e.g. body {}) will result in a nil redacted_fields attribute + Type: schema.TypeList, + Optional: true, + MaxItems: 100, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "method": emptySchema(), + "query_string": emptySchema(), + "single_header": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 40), + // The value is returned in lower case by the API. + // Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work. + validation.StringMatch(regexp.MustCompile(`^[a-z0-9-_]+$`), "must contain only lowercase alphanumeric characters, underscores, and hyphens"), + ), + }, }, }, }, + "uri_path": emptySchema(), }, - "uri_path": emptySchema(), }, + Description: "Parts of the request to exclude from logs", + DiffSuppressFunc: suppressRedactedFieldsDiff, }, - Description: "Parts of the request to exclude from logs", - DiffSuppressFunc: suppressRedactedFieldsDiff, - }, - "resource_arn": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidARN, - Description: "AWS WebACL ARN", - }, + "resource_arn": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: verify.ValidARN, + Description: "AWS WebACL ARN", + }, + } }, } } From d4480310a8ad171c406cceaa5877d0c5d359f397 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 12:16:47 -0400 Subject: [PATCH 10/20] OpsWorks Layers: Implement 'SchemaFunc()'. --- internal/service/opsworks/layers.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/service/opsworks/layers.go b/internal/service/opsworks/layers.go index 67df766f22e9..cb90900c6828 100644 --- a/internal/service/opsworks/layers.go +++ b/internal/service/opsworks/layers.go @@ -458,7 +458,9 @@ func (lt *opsworksLayerType) resourceSchema() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: resourceSchema, + SchemaFunc: func() map[string]*schema.Schema { + return resourceSchema + }, CustomizeDiff: verify.SetTagsDiff, } From c1071283f1f14cd05bbcfed3d754d5fb82ee12e9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 12:19:32 -0400 Subject: [PATCH 11/20] r/aws_medialive_channel: Implement 'SchemaFunc()'. --- internal/service/medialive/channel.go | 1100 +++++++++++++------------ 1 file changed, 551 insertions(+), 549 deletions(-) diff --git a/internal/service/medialive/channel.go b/internal/service/medialive/channel.go index 7661138010c5..01cb255b9f62 100644 --- a/internal/service/medialive/channel.go +++ b/internal/service/medialive/channel.go @@ -44,177 +44,179 @@ func ResourceChannel() *schema.Resource { Delete: schema.DefaultTimeout(15 * time.Minute), }, - Schema: map[string]*schema.Schema{ - "arn": { - Type: schema.TypeString, - Computed: true, - }, - "cdi_input_specification": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resolution": { - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: enum.Validate[types.CdiInputResolution](), + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "cdi_input_specification": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "resolution": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[types.CdiInputResolution](), + }, }, }, }, - }, - "channel_class": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateDiagFunc: enum.Validate[types.ChannelClass](), - }, - "channel_id": { - Type: schema.TypeString, - Computed: true, - }, - "destinations": { - Type: schema.TypeSet, - Required: true, - MinItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Required: true, - }, - "media_package_settings": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "channel_id": { - Type: schema.TypeString, - Required: true, + "channel_class": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: enum.Validate[types.ChannelClass](), + }, + "channel_id": { + Type: schema.TypeString, + Computed: true, + }, + "destinations": { + Type: schema.TypeSet, + Required: true, + MinItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Required: true, + }, + "media_package_settings": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "channel_id": { + Type: schema.TypeString, + Required: true, + }, }, }, }, - }, - "multiplex_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "multiplex_id": { - Type: schema.TypeString, - Required: true, - }, - "program_name": { - Type: schema.TypeString, - Required: true, + "multiplex_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "multiplex_id": { + Type: schema.TypeString, + Required: true, + }, + "program_name": { + Type: schema.TypeString, + Required: true, + }, }, }, }, - }, - "settings": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "password_param": { - Type: schema.TypeString, - Optional: true, - }, - "stream_name": { - Type: schema.TypeString, - Optional: true, - }, - "url": { - Type: schema.TypeString, - Optional: true, - }, - "username": { - Type: schema.TypeString, - Optional: true, + "settings": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "password_param": { + Type: schema.TypeString, + Optional: true, + }, + "stream_name": { + Type: schema.TypeString, + Optional: true, + }, + "url": { + Type: schema.TypeString, + Optional: true, + }, + "username": { + Type: schema.TypeString, + Optional: true, + }, }, }, }, }, }, }, - }, - "encoder_settings": func() *schema.Schema { - return channelEncoderSettingsSchema() - }(), - "input_attachments": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "automatic_input_failover_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "secondary_input_id": { - Type: schema.TypeString, - Required: true, - }, - "error_clear_time_msec": { - Type: schema.TypeInt, - Optional: true, - }, - "failover_condition": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "failover_condition_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "audio_silence_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "audio_selector_name": { - Type: schema.TypeString, - Required: true, - }, - "audio_silence_threshold_msec": { - Type: schema.TypeInt, - Optional: true, + "encoder_settings": func() *schema.Schema { + return channelEncoderSettingsSchema() + }(), + "input_attachments": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "automatic_input_failover_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "secondary_input_id": { + Type: schema.TypeString, + Required: true, + }, + "error_clear_time_msec": { + Type: schema.TypeInt, + Optional: true, + }, + "failover_condition": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "failover_condition_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "audio_silence_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "audio_selector_name": { + Type: schema.TypeString, + Required: true, + }, + "audio_silence_threshold_msec": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "input_loss_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "input_loss_threshold_msec": { - Type: schema.TypeInt, - Optional: true, + "input_loss_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "input_loss_threshold_msec": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "video_black_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "black_detect_threshold": { - Type: schema.TypeFloat, - Optional: true, - }, - "video_black_threshold_msec": { - Type: schema.TypeInt, - Optional: true, + "video_black_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "black_detect_threshold": { + Type: schema.TypeFloat, + Optional: true, + }, + "video_black_threshold_msec": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, @@ -224,107 +226,107 @@ func ResourceChannel() *schema.Resource { }, }, }, - }, - "input_preference": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.InputPreference](), + "input_preference": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.InputPreference](), + }, }, }, }, - }, - "input_attachment_name": { - Type: schema.TypeString, - Required: true, - }, - "input_id": { - Type: schema.TypeString, - Required: true, - }, - "input_settings": { - Type: schema.TypeList, - Optional: true, - Computed: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "audio_selector": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - "selector_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "audio_hls_rendition_selection": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "group_id": { - Type: schema.TypeString, - Required: true, - }, - "name": { - Type: schema.TypeString, - Required: true, + "input_attachment_name": { + Type: schema.TypeString, + Required: true, + }, + "input_id": { + Type: schema.TypeString, + Required: true, + }, + "input_settings": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "audio_selector": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "selector_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "audio_hls_rendition_selection": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "group_id": { + Type: schema.TypeString, + Required: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + }, }, }, }, - }, - "audio_language_selection": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "language_code": { - Type: schema.TypeString, - Required: true, - }, - "language_selection_policy": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.AudioLanguageSelectionPolicy](), + "audio_language_selection": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "language_code": { + Type: schema.TypeString, + Required: true, + }, + "language_selection_policy": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.AudioLanguageSelectionPolicy](), + }, }, }, }, - }, - "audio_pid_selection": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pid": { - Type: schema.TypeInt, - Required: true, + "audio_pid_selection": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "pid": { + Type: schema.TypeInt, + Required: true, + }, }, }, }, - }, - "audio_track_selection": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "track": { - Type: schema.TypeSet, - Required: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "track": { - Type: schema.TypeInt, - Required: true, + "audio_track_selection": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "track": { + Type: schema.TypeSet, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "track": { + Type: schema.TypeInt, + Required: true, + }, }, }, }, @@ -337,154 +339,154 @@ func ResourceChannel() *schema.Resource { }, }, }, - }, - "caption_selector": { - Type: schema.TypeList, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - "language_code": { - Type: schema.TypeString, - Optional: true, - }, - "selector_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ancillary_source_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "source_ancillary_channel_number": { - Type: schema.TypeInt, - Optional: true, + "caption_selector": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + }, + "language_code": { + Type: schema.TypeString, + Optional: true, + }, + "selector_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ancillary_source_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "source_ancillary_channel_number": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "dvb_tdt_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ocr_language": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.DvbSubOcrLanguage](), - }, - "pid": { - Type: schema.TypeInt, - Optional: true, + "dvb_tdt_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ocr_language": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.DvbSubOcrLanguage](), + }, + "pid": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "embedded_source_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "convert_608_to_708": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.EmbeddedConvert608To708](), - }, - "scte20_detection": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.EmbeddedScte20Detection](), - }, - "source_608_channel_number": { - Type: schema.TypeInt, - Optional: true, - }, - "source_608_track_number": { - Type: schema.TypeInt, - Optional: true, + "embedded_source_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "convert_608_to_708": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.EmbeddedConvert608To708](), + }, + "scte20_detection": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.EmbeddedScte20Detection](), + }, + "source_608_channel_number": { + Type: schema.TypeInt, + Optional: true, + }, + "source_608_track_number": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "scte20_source_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "convert_608_to_708": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.Scte20Convert608To708](), - }, - "source_608_channel_number": { - Type: schema.TypeInt, - Optional: true, + "scte20_source_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "convert_608_to_708": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.Scte20Convert608To708](), + }, + "source_608_channel_number": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "scte27_source_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ocr_language": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.Scte27OcrLanguage](), - }, - "pid": { - Type: schema.TypeInt, - Optional: true, + "scte27_source_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ocr_language": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.Scte27OcrLanguage](), + }, + "pid": { + Type: schema.TypeInt, + Optional: true, + }, }, }, }, - }, - "teletext_source_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "output_rectangle": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "height": { - Type: schema.TypeFloat, - Required: true, - }, - "left_offset": { - Type: schema.TypeFloat, - Required: true, - }, - "top_offset": { - Type: schema.TypeFloat, - Required: true, - }, - "width": { - Type: schema.TypeFloat, - Required: true, + "teletext_source_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "output_rectangle": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "height": { + Type: schema.TypeFloat, + Required: true, + }, + "left_offset": { + Type: schema.TypeFloat, + Required: true, + }, + "top_offset": { + Type: schema.TypeFloat, + Required: true, + }, + "width": { + Type: schema.TypeFloat, + Required: true, + }, }, }, }, - }, - "page_number": { - Type: schema.TypeString, - Optional: true, + "page_number": { + Type: schema.TypeString, + Optional: true, + }, }, }, }, @@ -494,104 +496,104 @@ func ResourceChannel() *schema.Resource { }, }, }, - }, - "deblock_filter": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.InputDeblockFilter](), - }, - "denoise_filter": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.InputDenoiseFilter](), - }, - "filter_strength": { - Type: schema.TypeInt, - Optional: true, - ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 5)), - }, - "input_filter": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateDiagFunc: enum.Validate[types.InputFilter](), - }, - "network_input_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "hls_input_settings": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "bandwidth": { - Type: schema.TypeInt, - Optional: true, - }, - "buffer_segments": { - Type: schema.TypeInt, - Optional: true, - }, - "retries": { - Type: schema.TypeInt, - Optional: true, - }, - "retry_interval": { - Type: schema.TypeInt, - Optional: true, - }, - "scte35_source": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.HlsScte35SourceType](), + "deblock_filter": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.InputDeblockFilter](), + }, + "denoise_filter": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.InputDenoiseFilter](), + }, + "filter_strength": { + Type: schema.TypeInt, + Optional: true, + ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 5)), + }, + "input_filter": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateDiagFunc: enum.Validate[types.InputFilter](), + }, + "network_input_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "hls_input_settings": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bandwidth": { + Type: schema.TypeInt, + Optional: true, + }, + "buffer_segments": { + Type: schema.TypeInt, + Optional: true, + }, + "retries": { + Type: schema.TypeInt, + Optional: true, + }, + "retry_interval": { + Type: schema.TypeInt, + Optional: true, + }, + "scte35_source": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.HlsScte35SourceType](), + }, }, }, }, - }, - "server_validation": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.NetworkInputServerValidation](), + "server_validation": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.NetworkInputServerValidation](), + }, }, }, }, - }, - "scte35_pid": { - Type: schema.TypeInt, - Optional: true, - }, - "smpte2038_data_preference": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.Smpte2038DataPreference](), - }, - "source_end_behavior": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.InputSourceEndBehavior](), - }, - "video_selector": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "color_space": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.VideoSelectorColorSpace](), - }, - // TODO implement color_space_settings - "color_space_usage": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: enum.Validate[types.VideoSelectorColorSpaceUsage](), + "scte35_pid": { + Type: schema.TypeInt, + Optional: true, + }, + "smpte2038_data_preference": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.Smpte2038DataPreference](), + }, + "source_end_behavior": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.InputSourceEndBehavior](), + }, + "video_selector": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "color_space": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.VideoSelectorColorSpace](), + }, + // TODO implement color_space_settings + "color_space_usage": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: enum.Validate[types.VideoSelectorColorSpaceUsage](), + }, + // TODO implement selector_settings }, - // TODO implement selector_settings }, }, }, @@ -600,104 +602,104 @@ func ResourceChannel() *schema.Resource { }, }, }, - }, - "input_specification": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "codec": { - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: enum.Validate[types.InputCodec](), - }, - "maximum_bitrate": { - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: enum.Validate[types.InputMaximumBitrate](), - }, - "input_resolution": { - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: enum.Validate[types.InputResolution](), + "input_specification": { + Type: schema.TypeList, + Required: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "codec": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[types.InputCodec](), + }, + "maximum_bitrate": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[types.InputMaximumBitrate](), + }, + "input_resolution": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[types.InputResolution](), + }, }, }, }, - }, - "log_level": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateDiagFunc: enum.Validate[types.LogLevel](), - }, - "maintenance": { - Type: schema.TypeList, - Optional: true, - Computed: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "maintenance_day": { - Type: schema.TypeString, - Required: true, - ValidateDiagFunc: enum.Validate[types.MaintenanceDay](), - }, - "maintenance_start_time": { - Type: schema.TypeString, - Required: true, + "log_level": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateDiagFunc: enum.Validate[types.LogLevel](), + }, + "maintenance": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "maintenance_day": { + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[types.MaintenanceDay](), + }, + "maintenance_start_time": { + Type: schema.TypeString, + Required: true, + }, }, }, }, - }, - "name": { - Type: schema.TypeString, - Required: true, - }, - "role_arn": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: validation.ToDiagFunc(verify.ValidARN), - }, - "start_channel": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - "vpc": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - ForceNew: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "availability_zones": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "public_address_allocation_ids": { - Type: schema.TypeList, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "security_group_ids": { - Type: schema.TypeList, - Optional: true, - Computed: true, - MaxItems: 5, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "subnet_ids": { - Type: schema.TypeList, - Required: true, - Elem: &schema.Schema{Type: schema.TypeString}, + "name": { + Type: schema.TypeString, + Required: true, + }, + "role_arn": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: validation.ToDiagFunc(verify.ValidARN), + }, + "start_channel": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "vpc": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + ForceNew: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "availability_zones": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "public_address_allocation_ids": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "security_group_ids": { + Type: schema.TypeList, + Optional: true, + Computed: true, + MaxItems: 5, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "subnet_ids": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, }, }, }, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + } }, CustomizeDiff: verify.SetTagsDiff, From 784840954c1bacac62987a1c3284f98c67d895a6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 28 Jun 2023 16:07:07 -0400 Subject: [PATCH 12/20] Revert "Start pprof HTTP server." This reverts commit 243c2ee310078b9b927fbe745c433c45a2faf0a6. --- main.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/main.go b/main.go index 468a48297558..b40c75d2eb2e 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,6 @@ import ( "context" "flag" "log" - "net/http" - _ "net/http/pprof" "github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server" "github.com/hashicorp/terraform-provider-aws/internal/provider" @@ -21,10 +19,6 @@ func main() { log.Fatal(err) } - go func() { - http.ListenAndServe("localhost:8080", nil) - }() - var serveOpts []tf5server.ServeOpt if *debugFlag { From c267e7f76028b228b29d53b3d04f3379701edf4f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 29 Jun 2023 17:02:52 -0400 Subject: [PATCH 13/20] Use 'schema.Resource.SchemaMap()' for schema during provider initialization. --- internal/provider/provider.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index d21656b62bd8..013dacf080e9 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -323,27 +323,27 @@ func New(ctx context.Context) (*schema.Provider, error) { interceptors := interceptorItems{} if v.Tags != nil { - if r.SchemaFunc == nil { - // The resource has opted in to transparent tagging. - // Ensure that the schema look OK. - if v, ok := r.Schema[names.AttrTags]; ok { - if v.Computed { - errs = multierror.Append(errs, fmt.Errorf("`%s` attribute cannot be Computed: %s", names.AttrTags, typeName)) - continue - } - } else { - errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTags, typeName)) + schema := r.SchemaMap() + + // The resource has opted in to transparent tagging. + // Ensure that the schema look OK. + if v, ok := schema[names.AttrTags]; ok { + if v.Computed { + errs = multierror.Append(errs, fmt.Errorf("`%s` attribute cannot be Computed: %s", names.AttrTags, typeName)) continue } - if v, ok := r.Schema[names.AttrTagsAll]; ok { - if !v.Computed { - errs = multierror.Append(errs, fmt.Errorf("`%s` attribute must be Computed: %s", names.AttrTags, typeName)) - continue - } - } else { - errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTagsAll, typeName)) + } else { + errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTags, typeName)) + continue + } + if v, ok := schema[names.AttrTagsAll]; ok { + if !v.Computed { + errs = multierror.Append(errs, fmt.Errorf("`%s` attribute must be Computed: %s", names.AttrTags, typeName)) continue } + } else { + errs = multierror.Append(errs, fmt.Errorf("no `%s` attribute defined in schema: %s", names.AttrTagsAll, typeName)) + continue } interceptors = append(interceptors, interceptorItem{ From 43360472a66804b9dedd24a10aff679b4694f98c Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 10:58:05 -0400 Subject: [PATCH 14/20] r/aws_autoscaling_group: Use 'resource.SchemaMap()'. --- internal/service/autoscaling/group.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index d353f28bc0c8..69d1a795a873 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -3882,7 +3882,7 @@ func validateGroupInstanceRefreshTriggerFields(i interface{}, path cty.Path) dia } } - schema := ResourceGroup().Schema + schema := ResourceGroup().SchemaMap() for attr, attrSchema := range schema { if v == attr { if attrSchema.Computed && !attrSchema.Optional { From e97c28b68dcb25a44cb41561a33ff51960dedba7 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 11:01:09 -0400 Subject: [PATCH 15/20] r/aws_spot_instance_request: Use 'resource.SchemaMap()'. --- internal/service/ec2/ec2_spot_instance_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/ec2/ec2_spot_instance_request.go b/internal/service/ec2/ec2_spot_instance_request.go index ecd794c3ae91..062218553b79 100644 --- a/internal/service/ec2/ec2_spot_instance_request.go +++ b/internal/service/ec2/ec2_spot_instance_request.go @@ -42,7 +42,7 @@ func ResourceSpotInstanceRequest() *schema.Resource { Schema: func() map[string]*schema.Schema { // The Spot Instance Request Schema is based on the AWS Instance schema. - s := ResourceInstance().Schema + s := ResourceInstance().SchemaMap() // Everything on a spot instance is ForceNew (except tags). for k, v := range s { From ed06427a47563ff1259aeed5df99bf25417cb18b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 11:03:38 -0400 Subject: [PATCH 16/20] ec2_instance_test: Use 'resource.SchemaMap()'. --- internal/service/ec2/ec2_instance_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/ec2/ec2_instance_test.go b/internal/service/ec2/ec2_instance_test.go index 8bbdbe7dbe23..cb735578fa94 100644 --- a/internal/service/ec2/ec2_instance_test.go +++ b/internal/service/ec2/ec2_instance_test.go @@ -5426,7 +5426,7 @@ func testAccCheckDetachVolumes(ctx context.Context, instance *ec2.Instance) reso func TestInstanceHostIDSchema(t *testing.T) { t.Parallel() - actualSchema := tfec2.ResourceInstance().Schema["host_id"] + actualSchema := tfec2.ResourceInstance().SchemaMap()["host_id"] expectedSchema := &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -5444,7 +5444,7 @@ func TestInstanceHostIDSchema(t *testing.T) { func TestInstanceCPUCoreCountSchema(t *testing.T) { t.Parallel() - actualSchema := tfec2.ResourceInstance().Schema["cpu_core_count"] + actualSchema := tfec2.ResourceInstance().SchemaMap()["cpu_core_count"] expectedSchema := &schema.Schema{ Type: schema.TypeInt, Optional: true, @@ -5464,7 +5464,7 @@ func TestInstanceCPUCoreCountSchema(t *testing.T) { func TestInstanceCPUThreadsPerCoreSchema(t *testing.T) { t.Parallel() - actualSchema := tfec2.ResourceInstance().Schema["cpu_threads_per_core"] + actualSchema := tfec2.ResourceInstance().SchemaMap()["cpu_threads_per_core"] expectedSchema := &schema.Schema{ Type: schema.TypeInt, Optional: true, From d4520cab91e783e007be6dfd8fe041ef474f456b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 11:08:58 -0400 Subject: [PATCH 17/20] waf: Use 'resource.SchemaMap()'. --- internal/service/waf/rule_group_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/waf/rule_group_test.go b/internal/service/waf/rule_group_test.go index 81a2f87f8da1..c48f718ee7b5 100644 --- a/internal/service/waf/rule_group_test.go +++ b/internal/service/waf/rule_group_test.go @@ -205,7 +205,7 @@ func TestAccWAFRuleGroup_changeActivatedRules(t *testing.T) { // which isn't static because ruleId is generated as part of the test func computeActivatedRuleWithRuleId(rule *waf.Rule, actionType string, priority int, idx *int) resource.TestCheckFunc { return func(s *terraform.State) error { - ruleResource := tfwaf.ResourceRuleGroup().Schema["activated_rule"].Elem.(*schema.Resource) + ruleResource := tfwaf.ResourceRuleGroup().SchemaMap()["activated_rule"].Elem.(*schema.Resource) m := map[string]interface{}{ "action": []interface{}{ From be4ba0d5d69384f51432fbb0cc9bec8d694ddd8e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 11:09:09 -0400 Subject: [PATCH 18/20] wafregional: Use 'resource.SchemaMap()'. --- internal/service/wafregional/rule_group_test.go | 2 +- internal/service/wafregional/rule_test.go | 2 +- internal/service/wafregional/web_acl_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/wafregional/rule_group_test.go b/internal/service/wafregional/rule_group_test.go index 476dacc8461b..3839425359fb 100644 --- a/internal/service/wafregional/rule_group_test.go +++ b/internal/service/wafregional/rule_group_test.go @@ -525,7 +525,7 @@ resource "aws_wafregional_rule_group" "test" { // which isn't static because ruleId is generated as part of the test func computeActivatedRuleWithRuleId(rule *waf.Rule, actionType string, priority int, idx *int) resource.TestCheckFunc { return func(s *terraform.State) error { - ruleResource := tfwafregional.ResourceRuleGroup().Schema["activated_rule"].Elem.(*schema.Resource) + ruleResource := tfwafregional.ResourceRuleGroup().SchemaMap()["activated_rule"].Elem.(*schema.Resource) m := map[string]interface{}{ "action": []interface{}{ diff --git a/internal/service/wafregional/rule_test.go b/internal/service/wafregional/rule_test.go index e6c4fcb67352..390470ae25ce 100644 --- a/internal/service/wafregional/rule_test.go +++ b/internal/service/wafregional/rule_test.go @@ -250,7 +250,7 @@ func TestAccWAFRegionalRule_changePredicates(t *testing.T) { // Calculates the index which isn't static because dataId is generated as part of the test func computeRulePredicate(dataId **string, negated bool, pType string, idx *int) resource.TestCheckFunc { return func(s *terraform.State) error { - predicateResource := tfwafregional.ResourceRule().Schema["predicate"].Elem.(*schema.Resource) + predicateResource := tfwafregional.ResourceRule().SchemaMap()["predicate"].Elem.(*schema.Resource) m := map[string]interface{}{ "data_id": **dataId, "negated": negated, diff --git a/internal/service/wafregional/web_acl_test.go b/internal/service/wafregional/web_acl_test.go index 07c02ee5388f..207520056366 100644 --- a/internal/service/wafregional/web_acl_test.go +++ b/internal/service/wafregional/web_acl_test.go @@ -404,7 +404,7 @@ func TestAccWAFRegionalWebACL_logging(t *testing.T) { // Calculates the index which isn't static because ruleId is generated as part of the test func computeWebACLRuleIndex(ruleId **string, priority int, ruleType string, actionType string, idx *int) resource.TestCheckFunc { return func(s *terraform.State) error { - ruleResource := tfwafregional.ResourceWebACL().Schema["rule"].Elem.(*schema.Resource) + ruleResource := tfwafregional.ResourceWebACL().SchemaMap()["rule"].Elem.(*schema.Resource) actionMap := map[string]interface{}{ "type": actionType, } From 3dac3edee83c5853be91838be0c5941e8102dac6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 11:26:02 -0400 Subject: [PATCH 19/20] Add 'testAccCheckSpotInstanceRequestIDsEqual' and 'testAccCheckSpotInstanceRequestIDsNotEqual'. --- .../ec2/ec2_spot_instance_request_test.go | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/internal/service/ec2/ec2_spot_instance_request_test.go b/internal/service/ec2/ec2_spot_instance_request_test.go index 8fe96150dc41..ce7d943beaf7 100644 --- a/internal/service/ec2/ec2_spot_instance_request_test.go +++ b/internal/service/ec2/ec2_spot_instance_request_test.go @@ -76,7 +76,7 @@ func TestAccEC2SpotInstanceRequest_disappears(t *testing.T) { func TestAccEC2SpotInstanceRequest_tags(t *testing.T) { ctx := acctest.Context(t) - var sir ec2.SpotInstanceRequest + var sir1, sir2, sir3 ec2.SpotInstanceRequest resourceName := "aws_spot_instance_request.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -89,7 +89,7 @@ func TestAccEC2SpotInstanceRequest_tags(t *testing.T) { { Config: testAccSpotInstanceRequestConfig_tags1(rName, "key1", "value1"), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir), + testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir1), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), ), @@ -103,7 +103,8 @@ func TestAccEC2SpotInstanceRequest_tags(t *testing.T) { { Config: testAccSpotInstanceRequestConfig_tags2(rName, "key1", "value1updated", "key2", "value2"), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir), + testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir2), + testAccCheckSpotInstanceRequestIDsEqual(&sir2, &sir1), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), @@ -112,7 +113,8 @@ func TestAccEC2SpotInstanceRequest_tags(t *testing.T) { { Config: testAccSpotInstanceRequestConfig_tags1(rName, "key2", "value2"), Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir), + testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir3), + testAccCheckSpotInstanceRequestIDsEqual(&sir3, &sir2), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), ), @@ -496,7 +498,7 @@ func TestAccEC2SpotInstanceRequest_interruptUpdate(t *testing.T) { Config: testAccSpotInstanceRequestConfig_interrupt(rName, "terminate"), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckSpotInstanceRequestExists(ctx, resourceName, &sir2), - testAccCheckSpotInstanceRequestRecreated(&sir1, &sir2), + testAccCheckSpotInstanceRequestIDsNotEqual(&sir1, &sir2), resource.TestCheckResourceAttr(resourceName, "instance_interruption_behavior", "terminate"), ), }, @@ -693,10 +695,20 @@ func testAccCheckSpotInstanceRequestAttributesVPC( } } -func testAccCheckSpotInstanceRequestRecreated(before, after *ec2.SpotInstanceRequest) resource.TestCheckFunc { +func testAccCheckSpotInstanceRequestIDsEqual(sir1, sir2 *ec2.SpotInstanceRequest) resource.TestCheckFunc { + return func(s *terraform.State) error { + if aws.StringValue(sir1.SpotInstanceRequestId) != aws.StringValue(sir2.SpotInstanceRequestId) { + return fmt.Errorf("Spot Instance Request IDs are not equal") + } + + return nil + } +} + +func testAccCheckSpotInstanceRequestIDsNotEqual(sir1, sir2 *ec2.SpotInstanceRequest) resource.TestCheckFunc { return func(s *terraform.State) error { - if before, after := aws.StringValue(before.InstanceId), aws.StringValue(after.InstanceId); before == after { - return fmt.Errorf("Spot Instance (%s) not recreated", before) + if aws.StringValue(sir1.SpotInstanceRequestId) == aws.StringValue(sir2.SpotInstanceRequestId) { + return fmt.Errorf("Spot Instance Request IDs are equal") } return nil From e52f8fdb8d8545e27e9558d3c9f5dda0ba55067a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 30 Jun 2023 11:48:23 -0400 Subject: [PATCH 20/20] r/aws_spot_instance_request: 'tags_all' is not ForceNew. --- internal/service/ec2/ec2_spot_instance_request.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/service/ec2/ec2_spot_instance_request.go b/internal/service/ec2/ec2_spot_instance_request.go index 0317c3ef256d..d7df9968cdf9 100644 --- a/internal/service/ec2/ec2_spot_instance_request.go +++ b/internal/service/ec2/ec2_spot_instance_request.go @@ -44,12 +44,13 @@ func ResourceSpotInstanceRequest() *schema.Resource { // The Spot Instance Request Schema is based on the AWS Instance schema. s := ResourceInstance().SchemaMap() - // Everything on a spot instance is ForceNew (except tags). + // Everything on a spot instance is ForceNew (except tags/tags_all). for k, v := range s { if v.Computed && !v.Optional { continue } - if k == names.AttrTags { + // tags_all is Optional+Computed. + if k == names.AttrTags || k == names.AttrTagsAll { continue } v.ForceNew = true