You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AWS S3 Bucket Policy object requires the name of the S3 Bucket inside the spec. Crossplane generally handles this by having a selector which you can use to find the right object, such as bucketNameSelector:
bucketNameSelector:
matchControllerRef: true
but in this case this is not enough because we also need the bucket ARN inside the object in spec.forProvider.policy.statements[0].resource[0].
In the latest crossplane-release we can achieve this using a patch with type: ToCompositeFieldPath to extract the information from the bucket object, back to a field in the composite object.
Step 1: Updating the schema
First we need to add a field to the schema of the composite object. We add status.bucketArn by updating the composite resource definition:
Now we can pull this information from status.atProvider.arn in the Bucket object up into our custom S3Bucket by writing a patch with type ToCompositeFieldPath:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The AWS S3 Bucket Policy object requires the name of the S3 Bucket inside the
spec
. Crossplane generally handles this by having a selector which you can use to find the right object, such asbucketNameSelector
:but in this case this is not enough because we also need the bucket ARN inside the object in
spec.forProvider.policy.statements[0].resource[0]
.In the latest crossplane-release we can achieve this using a patch with
type: ToCompositeFieldPath
to extract the information from the bucket object, back to a field in the composite object.Step 1: Updating the schema
First we need to add a field to the schema of the composite object. We add
status.bucketArn
by updating the composite resource definition:Step 2: Extracting the generated ARN back to the composite
By running kubectl get bucket -o yaml we can se that the ARN is available in the status of the bucket:
Now we can pull this information from
status.atProvider.arn
in the Bucket object up into our custom S3Bucket by writing a patch with typeToCompositeFieldPath
:Step 3: Storing the extracted information down into a base
Now we can update the S3 bucket policy with the ARN just like we would with a normal parameter. By default, a patch has type
FromCompositeFieldPath
.Beta Was this translation helpful? Give feedback.
All reactions