Skip to content

Instantly share code, notes, and snippets.

@jonashackt
Created June 29, 2022 14:02
Show Gist options
  • Select an option

  • Save jonashackt/dd3a770e811a82e419f2f0cf6f4800c8 to your computer and use it in GitHub Desktop.

Select an option

Save jonashackt/dd3a770e811a82e419f2f0cf6f4800c8 to your computer and use it in GitHub Desktop.

Revisions

  1. jonashackt created this gist Jun 29, 2022.
    57 changes: 57 additions & 0 deletions composition.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    ---
    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://doc.crds.dev/github.com/crossplane/provider-aws/s3.aws.crossplane.io/Bucket/[email protected]
    apiVersion: s3.aws.crossplane.io/v1beta1
    kind: Bucket
    metadata: {}
    spec:
    forProvider:
    # public-read should enable public access for static website hosting
    # see https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket
    acl: "public-read"
    websiteConfiguration:
    indexDocument:
    suffix: "index.html"
    deletionPolicy: Delete

    # Each resource can optionally specify a set of 'patches' that copy fields
    # from (or to) the XR.
    patches:
    # All those fieldPath refer to XR or Claim spec.parameters
    - fromFieldPath: "spec.parameters.bucketName"
    toFieldPath: "metadata.name"
    - fromFieldPath: "spec.parameters.region"
    toFieldPath: "spec.forProvider.locationConstraint"

    # 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: