diff --git a/apis/s3/v1beta1/zz_directorybucket_types.go b/apis/s3/v1beta1/zz_directorybucket_types.go index 0399c6522d..4a417008b1 100755 --- a/apis/s3/v1beta1/zz_directorybucket_types.go +++ b/apis/s3/v1beta1/zz_directorybucket_types.go @@ -22,7 +22,7 @@ type DirectoryBucketInitParameters struct { ForceDestroy *bool `json:"forceDestroy,omitempty" tf:"force_destroy,omitempty"` // Bucket location. See Location below for more details. - Location []LocationInitParameters `json:"location,omitempty" tf:"location,omitempty"` + Location *LocationInitParameters `json:"location,omitempty" tf:"location,omitempty"` // Bucket type. Valid values: Directory. Type *string `json:"type,omitempty" tf:"type,omitempty"` @@ -43,7 +43,7 @@ type DirectoryBucketObservation struct { ID *string `json:"id,omitempty" tf:"id,omitempty"` // Bucket location. See Location below for more details. - Location []LocationObservation `json:"location,omitempty" tf:"location,omitempty"` + Location *LocationObservation `json:"location,omitempty" tf:"location,omitempty"` // Bucket type. Valid values: Directory. Type *string `json:"type,omitempty" tf:"type,omitempty"` @@ -61,7 +61,7 @@ type DirectoryBucketParameters struct { // Bucket location. See Location below for more details. // +kubebuilder:validation:Optional - Location []LocationParameters `json:"location,omitempty" tf:"location,omitempty"` + Location *LocationParameters `json:"location,omitempty" tf:"location,omitempty"` // Region is the region you'd like your resource to be created in. // +upjet:crd:field:TFTag=- diff --git a/apis/s3/v1beta1/zz_generated.deepcopy.go b/apis/s3/v1beta1/zz_generated.deepcopy.go index 240a21e391..22153cbf16 100644 --- a/apis/s3/v1beta1/zz_generated.deepcopy.go +++ b/apis/s3/v1beta1/zz_generated.deepcopy.go @@ -8542,10 +8542,8 @@ func (in *DirectoryBucketInitParameters) DeepCopyInto(out *DirectoryBucketInitPa } if in.Location != nil { in, out := &in.Location, &out.Location - *out = make([]LocationInitParameters, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + *out = new(LocationInitParameters) + (*in).DeepCopyInto(*out) } if in.Type != nil { in, out := &in.Type, &out.Type @@ -8621,10 +8619,8 @@ func (in *DirectoryBucketObservation) DeepCopyInto(out *DirectoryBucketObservati } if in.Location != nil { in, out := &in.Location, &out.Location - *out = make([]LocationObservation, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + *out = new(LocationObservation) + (*in).DeepCopyInto(*out) } if in.Type != nil { in, out := &in.Type, &out.Type @@ -8658,10 +8654,8 @@ func (in *DirectoryBucketParameters) DeepCopyInto(out *DirectoryBucketParameters } if in.Location != nil { in, out := &in.Location, &out.Location - *out = make([]LocationParameters, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + *out = new(LocationParameters) + (*in).DeepCopyInto(*out) } if in.Region != nil { in, out := &in.Region, &out.Region diff --git a/config/overrides.go b/config/overrides.go index 48896b2846..25281e8443 100644 --- a/config/overrides.go +++ b/config/overrides.go @@ -213,3 +213,23 @@ func injectFieldRenamingConversionFunctions() config.ResourceOption { } } } + +// setMaxItemsConstraintsOnFrameworkResources configures the MaxItems +// constraints on framework resources. For some Terraform framework resources +// such as the aws_s3_directory_bucket, the max items constraint is specified +// via the listvalidator.SizeAtMost validator: +// https://github.com/hashicorp/terraform-provider-aws/blob/3d69baf5b6762008170af6bf17c963ccc17d5174/internal/service/s3/directory_bucket.go#L121 +// Unfortunately, this constraint is *not* available in the JSON schema +// and thus, is not available to the singleton list embedder. +// So, for now, we need to manually configure the MaxItems SDK constraint for +// the resource. +func setMaxItemsConstraintsOnFrameworkResources() config.ResourceOption { + return func(r *config.Resource) { + switch r.Name { + case "aws_s3_directory_bucket": + r.TerraformResource.Schema["location"].MaxItems = 1 + default: + return + } + } +} diff --git a/config/registry.go b/config/registry.go index ea0f176ea9..4d8f159531 100644 --- a/config/registry.go +++ b/config/registry.go @@ -161,6 +161,7 @@ func GetProvider(ctx context.Context, generationProvider bool) (*config.Provider NamePrefixRemoval(), DocumentationForTags(), injectFieldRenamingConversionFunctions(), + setMaxItemsConstraintsOnFrameworkResources(), ), ) pc.BasePackages.ControllerMap["internal/controller/eks/clusterauth"] = "eks" diff --git a/examples/s3/v1beta1/directorybucket.yaml b/examples/s3/v1beta1/directorybucket.yaml index c7b7a54871..27e07e89af 100644 --- a/examples/s3/v1beta1/directorybucket.yaml +++ b/examples/s3/v1beta1/directorybucket.yaml @@ -11,5 +11,5 @@ metadata: spec: forProvider: location: - - name: usw2-az1 + name: usw2-az1 region: us-west-2 diff --git a/package/crds/s3.aws.upbound.io_directorybuckets.yaml b/package/crds/s3.aws.upbound.io_directorybuckets.yaml index 74901beb40..acd9bfe989 100644 --- a/package/crds/s3.aws.upbound.io_directorybuckets.yaml +++ b/package/crds/s3.aws.upbound.io_directorybuckets.yaml @@ -87,16 +87,14 @@ spec: type: boolean location: description: Bucket location. See Location below for more details. - items: - properties: - name: - description: Availability Zone ID. - type: string - type: - description: 'Location type. Valid values: AvailabilityZone.' - type: string - type: object - type: array + properties: + name: + description: Availability Zone ID. + type: string + type: + description: 'Location type. Valid values: AvailabilityZone.' + type: string + type: object region: description: Region is the region you'd like your resource to be created in. @@ -134,16 +132,14 @@ spec: type: boolean location: description: Bucket location. See Location below for more details. - items: - properties: - name: - description: Availability Zone ID. - type: string - type: - description: 'Location type. Valid values: AvailabilityZone.' - type: string - type: object - type: array + properties: + name: + description: Availability Zone ID. + type: string + type: + description: 'Location type. Valid values: AvailabilityZone.' + type: string + type: object type: description: 'Bucket type. Valid values: Directory.' type: string @@ -340,16 +336,14 @@ spec: type: string location: description: Bucket location. See Location below for more details. - items: - properties: - name: - description: Availability Zone ID. - type: string - type: - description: 'Location type. Valid values: AvailabilityZone.' - type: string - type: object - type: array + properties: + name: + description: Availability Zone ID. + type: string + type: + description: 'Location type. Valid values: AvailabilityZone.' + type: string + type: object type: description: 'Bucket type. Valid values: Directory.' type: string