definitions.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
# XRDs must be named 'x<plural>.<group>'
name: xobjectstorages.crossplane.evina
spec:
# This XRD defines an XR in the 'crossplane.evina' API group.
# The XR or Claim must use this group together with the spec.versions[0].name as it's apiVersion, like this:
# 'crossplane.evina/v1alpha1'
group: crossplane.evina
# XR names should always be prefixed with an 'X'
names:
kind: XObjectStorage
plural: xobjectstorages
# This type of XR offers a claim, which should have the same name without the 'X' prefix
claimNames:
kind: ObjectStorage
plural: objectstorages
# default Composition when none is specified (must match metadata.name of a provided Composition)
# e.g. in composition.yaml
defaultCompositionRef:
name: objectstorage-composition
versions:
- name: v1alpha1
served: true
referenceable: true
# OpenAPI schema (like the one used by Kubernetes CRDs). Determines what fields
# the XR (and claim) will have. Will be automatically extended by crossplane.
# See https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/
# for full CRD documentation and guide on how to write OpenAPI schemas
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
# We define 2 needed parameters here one has to provide as XR or Claim spec.parameters
properties:
parameters:
type: object
properties:
bucketName:
type: string
region:
type: string
required:
- bucketName
- region
compositions.yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: objectstorage-composition
labels:
# An optional convention is to include a label of the XRD. This allows
# easy discovery of compatible Compositions.
crossplane.io/xrd: xobjectstorages.crossplane.jonashackt.io
# The following label marks this Composition for AWS. This label can
# be used in 'compositionSelector' in an XR or Claim.
provider: aws
spec:
# Each Composition must declare that it is compatible with a particular type
# of Composite Resource using its 'compositeTypeRef' field. The referenced
# version must be marked 'referenceable' in the XRD that defines the XR.
compositeTypeRef:
apiVersion: crossplane.jonashackt.io/v1alpha1
kind: XObjectStorage
# When an XR is created in response to a claim Crossplane needs to know where
# it should create the XR's connection secret. This is configured using the
# 'writeConnectionSecretsToNamespace' field.
writeConnectionSecretsToNamespace: crossplane-system
# Each Composition must specify at least one composed resource template.
resources:
# Providing a unique name for each entry is good practice.
# Only identifies the resources entry within the Composition. Required in future crossplane API versions.
- name: bucket
base:
# see https://marketplace.upbound.io/providers/upbound/provider-aws/v0.34.0/resources/s3.aws.upbound.io/Bucket/v1beta1
apiVersion: s3.aws.upbound.io/v1beta1
kind: Bucket
metadata: {}
spec:
deletionPolicy: Delete
patches:
- fromFieldPath: "spec.parameters.bucketName"
toFieldPath: "metadata.name"
- fromFieldPath: "spec.parameters.region"
toFieldPath: "spec.forProvider.region"
- name: bucketpublicaccessblock
base:
# see https://marketplace.upbound.io/providers/upbound/provider-aws/v0.34.0/resources/s3.aws.upbound.io/BucketPublicAccessBlock/v1beta1
apiVersion: s3.aws.upbound.io/v1beta1
kind: BucketPublicAccessBlock
spec:
forProvider:
blockPublicAcls: false
blockPublicPolicy: false
ignorePublicAcls: false
restrictPublicBuckets: false
patches:
- fromFieldPath: "spec.parameters.bucketPABName"
toFieldPath: "metadata.name"
- fromFieldPath: "spec.parameters.bucketName"
toFieldPath: "spec.forProvider.bucketRef.name"
- fromFieldPath: "spec.parameters.region"
toFieldPath: "spec.forProvider.region"
- name: bucketownershipcontrols
base:
# see https://marketplace.upbound.io/providers/upbound/provider-aws/v0.34.0/resources/s3.aws.upbound.io/BucketOwnershipControls/v1beta1#doc:spec-forProvider-rule-objectOwnership
apiVersion: s3.aws.upbound.io/v1beta1
kind: BucketOwnershipControls
spec:
forProvider:
rule:
- objectOwnership: ObjectWriter
patches:
- fromFieldPath: "spec.parameters.bucketOSCName"
toFieldPath: "metadata.name"
- fromFieldPath: "spec.parameters.bucketName"
toFieldPath: "spec.forProvider.bucketRef.name"
- fromFieldPath: "spec.parameters.region"
toFieldPath: "spec.forProvider.region"
- name: bucketacl
base:
# see https://marketplace.upbound.io/providers/upbound/provider-aws/v0.34.0/resources/s3.aws.upbound.io/BucketACL/v1beta1
apiVersion: s3.aws.upbound.io/v1beta1
kind: BucketACL
spec:
forProvider:
acl: "public-read"
patches:
- fromFieldPath: "spec.parameters.bucketAclName"
toFieldPath: "metadata.name"
- fromFieldPath: "spec.parameters.bucketName"
toFieldPath: "spec.forProvider.bucketRef.name"
- fromFieldPath: "spec.parameters.region"
toFieldPath: "spec.forProvider.region"
- name: bucketwebsiteconfiguration
base:
# see https://marketplace.upbound.io/providers/upbound/provider-aws/v0.34.0/resources/s3.aws.upbound.io/BucketWebsiteConfiguration/v1beta1
apiVersion: s3.aws.upbound.io/v1beta1
kind: BucketWebsiteConfiguration
spec:
forProvider:
indexDocument:
- suffix: index.html
patches:
- fromFieldPath: "spec.parameters.bucketWebConfName"
toFieldPath: "metadata.name"
- fromFieldPath: "spec.parameters.bucketName"
toFieldPath: "spec.forProvider.bucketRef.name"
- fromFieldPath: "spec.parameters.region"
toFieldPath: "spec.forProvider.region"
# If you find yourself repeating patches a lot you can group them as a named
# 'patch set' then use a PatchSet type patch to reference them.
#patchSets: