Skip to content

Commit

Permalink
Set the MaxItems=1 constraint on aws_s3_directory_bucket.location
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <[email protected]>
  • Loading branch information
ulucinar committed Aug 29, 2024
1 parent 01316ae commit c7e4f5e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 46 deletions.
6 changes: 3 additions & 3 deletions apis/s3/v1beta1/zz_directorybucket_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions apis/s3/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions config/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
1 change: 1 addition & 0 deletions config/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/s3/v1beta1/directorybucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ metadata:
spec:
forProvider:
location:
- name: usw2-az1
name: usw2-az1
region: us-west-2
54 changes: 24 additions & 30 deletions package/crds/s3.aws.upbound.io_directorybuckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c7e4f5e

Please sign in to comment.