From 51cb01420b87537afedac6471fda99d0e4d5deff Mon Sep 17 00:00:00 2001 From: Manabu McCloskey Date: Wed, 11 Sep 2024 08:41:53 -0700 Subject: [PATCH] add back crossplane compositions Signed-off-by: Manabu McCloskey --- .../crossplane-compositions.yaml | 22 +++++ .../s3/definition.yaml | 76 ++++++++++++++++++ .../s3/general-purpose.yaml | 80 +++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100755 crossplane-integrations/crossplane-compositions.yaml create mode 100644 crossplane-integrations/crossplane-compositions/s3/definition.yaml create mode 100644 crossplane-integrations/crossplane-compositions/s3/general-purpose.yaml diff --git a/crossplane-integrations/crossplane-compositions.yaml b/crossplane-integrations/crossplane-compositions.yaml new file mode 100755 index 0000000..51deb74 --- /dev/null +++ b/crossplane-integrations/crossplane-compositions.yaml @@ -0,0 +1,22 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: crossplane-compositions + namespace: argocd + labels: + env: dev + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: default + source: + repoURL: cnoe://crossplane-compositions + targetRevision: HEAD + path: "." + directory: + recurse: true + destination: + server: "https://kubernetes.default.svc" + namespace: crossplane-system + syncPolicy: + automated: {} diff --git a/crossplane-integrations/crossplane-compositions/s3/definition.yaml b/crossplane-integrations/crossplane-compositions/s3/definition.yaml new file mode 100644 index 0000000..b812896 --- /dev/null +++ b/crossplane-integrations/crossplane-compositions/s3/definition.yaml @@ -0,0 +1,76 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: apiextensions.crossplane.io/v1 +kind: CompositeResourceDefinition +metadata: + name: xobjectstorages.awsblueprints.io +spec: + claimNames: + kind: ObjectStorage + plural: objectstorages + group: awsblueprints.io + names: + kind: XObjectStorage + plural: xobjectstorages + connectionSecretKeys: + - region + - bucket-name + - s3-put-policy + versions: + - name: v1alpha1 + served: true + referenceable: true + schema: + openAPIV3Schema: + properties: + spec: + description: ObjectStorageSpec defines the desired state of ObjectStorage + properties: + resourceConfig: + description: ResourceConfig defines general properties of this AWS + resource. + properties: + deletionPolicy: + description: Defaults to Delete + enum: + - Delete + - Orphan + type: string + name: + description: Set the name of this resource in AWS to the value + provided by this field. + type: string + providerConfigName: + type: string + region: + type: string + tags: + items: + properties: + key: + type: string + value: + type: string + required: + - key + - value + type: object + type: array + required: + - providerConfigName + - region + - tags + type: object + required: + - resourceConfig + type: object + status: + description: ObjectStorageStatus defines the observed state of ObjectStorage + properties: + bucketName: + type: string + bucketArn: + type: string + type: object + type: object diff --git a/crossplane-integrations/crossplane-compositions/s3/general-purpose.yaml b/crossplane-integrations/crossplane-compositions/s3/general-purpose.yaml new file mode 100644 index 0000000..abee25e --- /dev/null +++ b/crossplane-integrations/crossplane-compositions/s3/general-purpose.yaml @@ -0,0 +1,80 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: s3bucket.awsblueprints.io + labels: + awsblueprints.io/provider: aws + awsblueprints.io/environment: dev + s3.awsblueprints.io/configuration: standard +spec: + writeConnectionSecretsToNamespace: crossplane-system + compositeTypeRef: + apiVersion: awsblueprints.io/v1alpha1 + kind: XObjectStorage + patchSets: + - name: common-fields + patches: + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.providerConfigName + toFieldPath: spec.providerConfigRef.name + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.deletionPolicy + toFieldPath: spec.deletionPolicy + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.region + toFieldPath: spec.forProvider.region + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.name + toFieldPath: metadata.annotations[crossplane.io/external-name] + resources: + - name: s3-bucket + connectionDetails: + - name: bucket-name + fromConnectionSecretKey: endpoint + - name: region + fromConnectionSecretKey: region + base: + apiVersion: s3.aws.crossplane.io/v1beta1 + kind: Bucket + spec: + deletionPolicy: Delete + forProvider: + objectOwnership: BucketOwnerEnforced + publicAccessBlockConfiguration: + blockPublicPolicy: true + restrictPublicBuckets: true + serverSideEncryptionConfiguration: + rules: + - applyServerSideEncryptionByDefault: + sseAlgorithm: AES256 + tagging: + tagSet: + - key: cnoe + value: "1" + patches: + - type: PatchSet + patchSetName: common-fields + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.tags + toFieldPath: spec.forProvider.tagging.tagSet + policy: + mergeOptions: + appendSlice: true + keepMapValues: true + - type: FromCompositeFieldPath + fromFieldPath: spec.resourceConfig.region + toFieldPath: spec.forProvider.locationConstraint + - fromFieldPath: spec.writeConnectionSecretToRef.namespace + toFieldPath: spec.writeConnectionSecretToRef.namespace + - type: ToCompositeFieldPath + fromFieldPath: metadata.annotations[crossplane.io/external-name] + toFieldPath: status.bucketName + - type: ToCompositeFieldPath + fromFieldPath: status.atProvider.arn + toFieldPath: status.bucketArn + - fromFieldPath: metadata.uid + toFieldPath: spec.writeConnectionSecretToRef.name + transforms: + - type: string + string: + fmt: "%s-bucket"