From abc87a84d75cb9064b13f8dde0dc03d67da4111d Mon Sep 17 00:00:00 2001 From: irizzant Date: Wed, 15 May 2024 22:28:31 +0200 Subject: [PATCH 01/15] first commit --- apis/composition.yaml | 50 +++++++++++++++++++++++++++++++ apis/functions.yaml | 6 ++++ apis/xr.yaml | 8 +++++ devbox.json | 14 +++++++++ devbox.lock | 69 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 apis/composition.yaml create mode 100644 apis/functions.yaml create mode 100644 apis/xr.yaml create mode 100644 devbox.json create mode 100644 devbox.lock diff --git a/apis/composition.yaml b/apis/composition.yaml new file mode 100644 index 0000000..fd9c7e6 --- /dev/null +++ b/apis/composition.yaml @@ -0,0 +1,50 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: example-inline +spec: + compositeTypeRef: + apiVersion: example.crossplane.io/v1beta1 + kind: XR + mode: Pipeline + pipeline: + - step: render-templates + functionRef: + name: function-go-templating + input: + apiVersion: gotemplating.fn.crossplane.io/v1beta1 + kind: GoTemplate + source: Inline + inline: + template: | + {{ $params := .observed.composite.resource.spec.parameters }} + {{ $desired := .composed.desired.composite.resource }} + + {{- define "providerConfigRef" }} + providerConfigRef: + name: {{ .observed.composite.resource.spec.parameters.id }} + {{- end }} + {{- define "networkId" }} + networks.aws.platform.upbound.io/network-id: {{ .observed.composite.resource.spec.parameters.id }} + {{- end }} + {{- define "region" }} + region: {{ .observed.composite.resource.spec.parameters.region }} + {{- end }} + + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: VPC + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("vpc") }} + spec: + forProvider: + cidrBlock: 192.168.0.0/16 + enableDnsHostnames: true + enableDnsSupport: true + tags: + Name: {{ .observed.composite.resource.metadata.name }} + {{- include "region" . | nindent 2 }} + {{ template "providerConfigRef" . }} + status: {{ (index .desired.composed "resource-name").resource.spec.widgets }} \ No newline at end of file diff --git a/apis/functions.yaml b/apis/functions.yaml new file mode 100644 index 0000000..f3e021c --- /dev/null +++ b/apis/functions.yaml @@ -0,0 +1,6 @@ +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: function-go-templating +spec: + package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 \ No newline at end of file diff --git a/apis/xr.yaml b/apis/xr.yaml new file mode 100644 index 0000000..2c15b49 --- /dev/null +++ b/apis/xr.yaml @@ -0,0 +1,8 @@ +apiVersion: aws.platform.upbound.io/v1alpha1 +kind: XNetwork +metadata: + name: ref-aws-network +spec: + parameters: + id: platform-ref-aws + region: us-west-2 diff --git a/devbox.json b/devbox.json new file mode 100644 index 0000000..00eb18f --- /dev/null +++ b/devbox.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.10.7/.schema/devbox.schema.json", + "packages": ["crossplane@latest"], + "shell": { + "init_hook": [ + "echo 'Welcome to devbox!' > /dev/null" + ], + "scripts": { + "test": [ + "echo \"Error: no test specified\" && exit 1" + ] + } + } +} diff --git a/devbox.lock b/devbox.lock new file mode 100644 index 0000000..650efe0 --- /dev/null +++ b/devbox.lock @@ -0,0 +1,69 @@ +{ + "lockfile_version": "1", + "packages": { + "crossplane@latest": { + "last_modified": "2024-05-13T18:06:16Z", + "resolved": "github:NixOS/nixpkgs/1daef0114a6074be56586f2cf81898ed142e1e44#crossplane", + "source": "devbox-search", + "version": "0.5.8", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/2kf88i0mrgiqqmi5ppvwkjy4rvjg52r8-python3.11-crossplane-0.5.8", + "default": true + }, + { + "name": "dist", + "path": "/nix/store/sp6m4f6lr84xmy89qcxkyxcxqh2k4k09-python3.11-crossplane-0.5.8-dist" + } + ], + "store_path": "/nix/store/2kf88i0mrgiqqmi5ppvwkjy4rvjg52r8-python3.11-crossplane-0.5.8" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/w1y44jk4b4s1qj9rrn0z9ygg4bk7f4fw-python3.11-crossplane-0.5.8", + "default": true + }, + { + "name": "dist", + "path": "/nix/store/wvgsrs83asv7jsq6ld2pp8qgysv3crvw-python3.11-crossplane-0.5.8-dist" + } + ], + "store_path": "/nix/store/w1y44jk4b4s1qj9rrn0z9ygg4bk7f4fw-python3.11-crossplane-0.5.8" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/90mp5kxb7bac37p0p8q4d38wv3djm0wz-python3.11-crossplane-0.5.8", + "default": true + }, + { + "name": "dist", + "path": "/nix/store/hjxshzb4zbj0q8j78krp8vy2v5dz2hia-python3.11-crossplane-0.5.8-dist" + } + ], + "store_path": "/nix/store/90mp5kxb7bac37p0p8q4d38wv3djm0wz-python3.11-crossplane-0.5.8" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/cgva3s7jbz8whz4wd1cqkbzbsdgi067b-python3.11-crossplane-0.5.8", + "default": true + }, + { + "name": "dist", + "path": "/nix/store/6y6l7isyi3ridw2c5h45h8s8wclcxbni-python3.11-crossplane-0.5.8-dist" + } + ], + "store_path": "/nix/store/cgva3s7jbz8whz4wd1cqkbzbsdgi067b-python3.11-crossplane-0.5.8" + } + } + } + } +} From f06065901c7fa0cd071c2cccc34996c1d3235c77 Mon Sep 17 00:00:00 2001 From: irizzant Date: Thu, 16 May 2024 14:08:20 +0200 Subject: [PATCH 02/15] chore: Add new functions and subnets to the API definition file --- apis/composition.yaml | 234 +++++++++++++++++++++++++++++++++++++++++- apis/definition.yaml | 32 ++++++ apis/functions.yaml | 9 +- apis/xr.yaml | 15 +++ 4 files changed, 284 insertions(+), 6 deletions(-) diff --git a/apis/composition.yaml b/apis/composition.yaml index fd9c7e6..be68ca5 100644 --- a/apis/composition.yaml +++ b/apis/composition.yaml @@ -18,11 +18,10 @@ spec: inline: template: | {{ $params := .observed.composite.resource.spec.parameters }} - {{ $desired := .composed.desired.composite.resource }} - + {{- define "providerConfigRef" }} providerConfigRef: - name: {{ .observed.composite.resource.spec.parameters.id }} + name: {{ .observed.composite.resource.spec.parameters.providerConfigName }} {{- end }} {{- define "networkId" }} networks.aws.platform.upbound.io/network-id: {{ .observed.composite.resource.spec.parameters.id }} @@ -30,6 +29,9 @@ spec: {{- define "region" }} region: {{ .observed.composite.resource.spec.parameters.region }} {{- end }} + {{- define "deletionPolicy" }} + deletionPolicy: {{ .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} + {{- end }} apiVersion: ec2.aws.upbound.io/v1beta1 kind: VPC @@ -46,5 +48,227 @@ spec: tags: Name: {{ .observed.composite.resource.metadata.name }} {{- include "region" . | nindent 2 }} - {{ template "providerConfigRef" . }} - status: {{ (index .desired.composed "resource-name").resource.spec.widgets }} \ No newline at end of file + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: InternetGateway + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("igw") }} + spec: + forProvider: + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + + {{ $region := .observed.composite.resource.spec.parameters.region }} + {{ $deletionPolicy := .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} + + {{- range $i, $subnet := $params.subnets }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: Subnet + metadata: + labels: + zone: {{ $subnet.availabilityZone }} + {{- if eq $subnet.type "private" }} + access: private + {{- else }} + access: public + {{- end }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} + annotations: + {{ setResourceNameAnnotation (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) }} + spec: + forProvider: + cidrBlock: 192.168.0.0/18 + {{ if eq $subnet.type "public" }} + mapPublicIpOnLaunch: true + {{ end }} + tags: + {{- if eq $subnet.type "private" }} + kubernetes.io/role/internal-elb: "1" + {{- else }} + kubernetes.io/role/elb: "1" + {{- end }} + {{- if eq $subnet.type "public" }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} + {{- end }} + region: {{ $region }} + vpcIdSelector: + matchControllerRef: true + availabilityZone: {{ $subnet.availabilityZone }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $deletionPolicy }} + {{- end }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: RouteTable + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("rt") }} + spec: + forProvider: + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: Route + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("route") }} + spec: + forProvider: + destinationCidrBlock: 0.0.0.0/0 + gatewayIdSelector: + matchControllerRef: true + routeTableIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: MainRouteTableAssociation + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("mrt") }} + spec: + forProvider: + routeTableIdSelector: + matchControllerRef: true + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + {{- range $i, $subnet := $params.subnets }} + --- + kind: RouteTableAssociation + metadata: + labels: + networks.aws.platform.upbound.io/network-id: {{ $params.id }} + annotations: + {{ setResourceNameAnnotation (printf "rta-%s-%s" $subnet.availabilityZone $subnet.type) }} + spec: + forProvider: + routeTableIdSelector: + matchControllerRef: true + subnetIdSelector: + matchControllerRef: true + region: {{ $region }} + matchLabels: + {{- if eq $subnet.type "private" }} + access: private + {{- else }} + access: public + {{- end }} + zone: {{ $subnet.availabilityZone }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $deletionPolicy }} + {{- end }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: SecurityGroup + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("sg") }} + spec: + forProvider: + description: Allow access to databases + name: platform-ref-aws-cluster + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: SecurityGroupRule + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("sgrp") }} + spec: + forProvider: + cidrBlocks: + - 0.0.0.0/0 + description: Everywhere + fromPort: 5432 + protocol: tcp + securityGroupIdSelector: + matchControllerRef: true + toPort: 5432 + type: ingress + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: SecurityGroupRule + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("sgrm") }} + spec: + forProvider: + cidrBlocks: + - 0.0.0.0/0 + description: Everywhere + fromPort: 3306 + protocol: tcp + securityGroupIdSelector: + matchControllerRef: true + toPort: 3306 + type: ingress + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: {{ .observed.composite.resource.apiVersion }} + kind: {{ .observed.composite.resource.kind }} + status: + vpcId: {{ dig "resources" "vpc" "resource" "status" "atProvider" "id" "" $.observed }} + subnetIds: + {{- range $i, $subnet := $params.subnets }} + - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + {{- end }} + publicSubnetIds: + {{- range $i, $subnet := $params.subnets }} + {{- if eq $subnet.type "public" }} + - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + {{- end }} + {{- end }} + privateSubnetIds: + {{- range $i, $subnet := $params.subnets }} + {{- if eq $subnet.type "private" }} + - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + {{- end }} + {{- end }} + securityGroupIds: + - {{ dig "resources" "sg" "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + - step: automatically-detect-ready-composed-resources + functionRef: + name: function-auto-ready + \ No newline at end of file diff --git a/apis/definition.yaml b/apis/definition.yaml index 453df24..b30fa2f 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -38,6 +38,38 @@ spec: description: Crossplane ProviderConfig to use for provisioning this resources type: string default: default + subnets: + type: array + items: + type: object + properties: + availabilityZone: + type: string + type: + type: string + enum: + - public + - private + cidrBlock: + type: string + description: Subnets to create in the VPC + required: + - availabilityZone + - type + - cidrBlock + default: + - availabilityZone: us-west-2a + type: public + cidrBlock: 192.168.0.0/18 + - availabilityZone: us-west-2b + type: public + cidrBlock: 192.168.64.0/18 + - availabilityZone: us-west-2a + type: private + cidrBlock: 192.168.128.0/18 + - availabilityZone: us-west-2b + type: private + cidrBlock: 192.168.192.0/18 required: - deletionPolicy - providerConfigName diff --git a/apis/functions.yaml b/apis/functions.yaml index f3e021c..c482b74 100644 --- a/apis/functions.yaml +++ b/apis/functions.yaml @@ -3,4 +3,11 @@ kind: Function metadata: name: function-go-templating spec: - package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 \ No newline at end of file + package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: function-auto-ready +spec: + package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.2.1 \ No newline at end of file diff --git a/apis/xr.yaml b/apis/xr.yaml index 2c15b49..9331f0c 100644 --- a/apis/xr.yaml +++ b/apis/xr.yaml @@ -6,3 +6,18 @@ spec: parameters: id: platform-ref-aws region: us-west-2 + deletionPolicy: Delete + providerConfigName: aws-provider-config + subnets: + - availabilityZone: us-west-2a + type: public + cidrBlock: 192.168.0.0/18 + - availabilityZone: us-west-2b + type: public + cidrBlock: 192.168.64.0/18 + - availabilityZone: us-west-2a + type: private + cidrBlock: 192.168.128.0/18 + - availabilityZone: us-west-2b + type: private + cidrBlock: 192.168.192.0/18 From fa9066485a81b16bb092192ac7f8c6623a2b1bbf Mon Sep 17 00:00:00 2001 From: irizzant Date: Thu, 16 May 2024 14:20:05 +0200 Subject: [PATCH 03/15] chore: Update API definition file with new functions and subnets --- apis/basic/composition.yaml | 781 +++++++++++--------------------- apis/composition.yaml | 274 ----------- apis/functions.yaml | 13 - apis/xr.yaml | 23 - examples/function/function.yaml | 11 +- examples/network-xr.yaml | 15 + 6 files changed, 285 insertions(+), 832 deletions(-) delete mode 100644 apis/composition.yaml delete mode 100644 apis/functions.yaml delete mode 100644 apis/xr.yaml diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index 33e6ea4..be68ca5 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -1,533 +1,274 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: xnetworks.aws.platform.upbound.io - labels: - provider: aws - type: basic + name: example-inline spec: - writeConnectionSecretsToNamespace: upbound-system compositeTypeRef: - apiVersion: aws.platform.upbound.io/v1alpha1 - kind: XNetwork + apiVersion: example.crossplane.io/v1beta1 + kind: XR mode: Pipeline pipeline: - - step: patch-and-transform + - step: render-templates functionRef: - name: crossplane-contrib-function-patch-and-transform + name: function-go-templating input: - apiVersion: pt.fn.crossplane.io/v1beta1 - kind: Resources - patchSets: - - name: providerConfigRef - patches: - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.providerConfigName - toFieldPath: spec.providerConfigRef.name - - name: deletionPolicy - patches: - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.deletionPolicy - toFieldPath: spec.deletionPolicy - - name: network-id - patches: - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.id - toFieldPath: metadata.labels[networks.aws.platform.upbound.io/network-id] - - name: network-id-tags - patches: - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.id - toFieldPath: spec.forProvider.tags[networks.aws.platform.upbound.io/network-id] - - name: region - patches: - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.region - resources: - - name: vpc - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: VPC - spec: - forProvider: - cidrBlock: 192.168.0.0/16 - enableDnsHostnames: true - enableDnsSupport: true - tags: - Name: "" - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: metadata.name - toFieldPath: spec.forProvider.tags["Name"] - - type: ToCompositeFieldPath - fromFieldPath: status.atProvider.id - toFieldPath: status.vpcId + apiVersion: gotemplating.fn.crossplane.io/v1beta1 + kind: GoTemplate + source: Inline + inline: + template: | + {{ $params := .observed.composite.resource.spec.parameters }} + + {{- define "providerConfigRef" }} + providerConfigRef: + name: {{ .observed.composite.resource.spec.parameters.providerConfigName }} + {{- end }} + {{- define "networkId" }} + networks.aws.platform.upbound.io/network-id: {{ .observed.composite.resource.spec.parameters.id }} + {{- end }} + {{- define "region" }} + region: {{ .observed.composite.resource.spec.parameters.region }} + {{- end }} + {{- define "deletionPolicy" }} + deletionPolicy: {{ .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} + {{- end }} - - name: internetGateway - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: InternetGateway - spec: - forProvider: - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: VPC + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("vpc") }} + spec: + forProvider: + cidrBlock: 192.168.0.0/16 + enableDnsHostnames: true + enableDnsSupport: true + tags: + Name: {{ .observed.composite.resource.metadata.name }} + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: InternetGateway + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("igw") }} + spec: + forProvider: + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} - - name: subnetPublicA - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Subnet - metadata: - labels: - access: public - spec: - forProvider: - cidrBlock: 192.168.0.0/18 - mapPublicIpOnLaunch: true - tags: - kubernetes.io/role/elb: "1" - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: network-id-tags - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.availabilityZone - transforms: - - type: string - string: - fmt: '%sa' - type: Format - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: metadata.labels[zone] - transforms: - - type: string - string: - fmt: '%sa' - type: Format - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.subnetIds[0] - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.publicSubnetIds[0] - - - name: subnetPublicB - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Subnet - metadata: - labels: - access: public - spec: - forProvider: - cidrBlock: 192.168.64.0/18 - mapPublicIpOnLaunch: true - tags: - kubernetes.io/role/elb: "1" - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: network-id-tags - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.availabilityZone - transforms: - - type: string - string: - fmt: '%sb' - type: Format - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: metadata.labels[zone] - transforms: - - type: string - string: - fmt: '%sb' - type: Format - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.subnetIds[1] - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.publicSubnetIds[1] - - - name: subnetPrivateA - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Subnet - metadata: - labels: - access: private - spec: - forProvider: - cidrBlock: 192.168.128.0/18 - tags: - kubernetes.io/role/internal-elb: "1" - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.availabilityZone - transforms: - - type: string - string: - fmt: '%sa' - type: Format - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: metadata.labels[zone] - transforms: - - type: string - string: - fmt: '%sa' - type: Format - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.subnetIds[2] - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.privateSubnetIds[0] + {{ $region := .observed.composite.resource.spec.parameters.region }} + {{ $deletionPolicy := .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} - - name: subnetPrivateB - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Subnet - metadata: - labels: + {{- range $i, $subnet := $params.subnets }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: Subnet + metadata: + labels: + zone: {{ $subnet.availabilityZone }} + {{- if eq $subnet.type "private" }} access: private - spec: - forProvider: - cidrBlock: 192.168.192.0/18 - tags: - kubernetes.io/role/internal-elb: "1" - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.availabilityZone - transforms: - - type: string - string: - fmt: '%sb' - type: Format - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: metadata.labels[zone] - transforms: - - type: string - string: - fmt: '%sb' - type: Format - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.subnetIds[3] - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.privateSubnetIds[1] - - - name: routeTable - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: RouteTable - spec: - forProvider: - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - - name: route - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Route - spec: - forProvider: - destinationCidrBlock: 0.0.0.0/0 - gatewayIdSelector: - matchControllerRef: true - routeTableIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - - name: mainRouteTableAssociation - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: MainRouteTableAssociation - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - - name: routeTableAssociationPublicA - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: RouteTableAssociation - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - subnetIdSelector: - matchControllerRef: true - matchLabels: - access: public - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.subnetIdSelector.matchLabels[zone] - transforms: - - type: string - string: - fmt: '%sa' - type: Format - - - name: routeTableAssociationPublicB - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: RouteTableAssociation - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - subnetIdSelector: - matchControllerRef: true - matchLabels: - access: public - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.subnetIdSelector.matchLabels[zone] - transforms: - - type: string - string: - fmt: '%sb' - type: Format - - - name: routeTableAssociationPrivateA - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: RouteTableAssociation - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - subnetIdSelector: - matchControllerRef: true - matchLabels: - access: private - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.subnetIdSelector.matchLabels[zone] - transforms: - - type: string - string: - fmt: '%sa' - type: Format - - - name: routeTableAssociationPrivateB - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: RouteTableAssociation - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - subnetIdSelector: - matchControllerRef: true - matchLabels: - access: private - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: FromCompositeFieldPath - fromFieldPath: spec.parameters.region - toFieldPath: spec.forProvider.subnetIdSelector.matchLabels[zone] - transforms: - - type: string - string: - fmt: '%sb' - type: Format - - - name: securityGroup - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: SecurityGroup - spec: - forProvider: - description: Allow access to databases - name: platform-ref-aws-cluster - vpcIdSelector: - matchControllerRef: true - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - type: ToCompositeFieldPath - fromFieldPath: metadata.annotations[crossplane.io/external-name] - toFieldPath: status.securityGroupIds[0] - - - name: securityGroupRulePostgres - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: SecurityGroupRule - spec: - forProvider: - cidrBlocks: - - 0.0.0.0/0 - description: Everywhere - fromPort: 5432 - protocol: tcp - securityGroupIdSelector: - matchControllerRef: true - toPort: 5432 - type: ingress - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region - - - name: securityGroupRuleMysql - base: - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: SecurityGroupRule - spec: - forProvider: - cidrBlocks: - - 0.0.0.0/0 - description: Everywhere - fromPort: 3306 - protocol: tcp - securityGroupIdSelector: - matchControllerRef: true - toPort: 3306 - type: ingress - patches: - - type: PatchSet - patchSetName: providerConfigRef - - type: PatchSet - patchSetName: deletionPolicy - - type: PatchSet - patchSetName: network-id - - type: PatchSet - patchSetName: region + {{- else }} + access: public + {{- end }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} + annotations: + {{ setResourceNameAnnotation (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) }} + spec: + forProvider: + cidrBlock: 192.168.0.0/18 + {{ if eq $subnet.type "public" }} + mapPublicIpOnLaunch: true + {{ end }} + tags: + {{- if eq $subnet.type "private" }} + kubernetes.io/role/internal-elb: "1" + {{- else }} + kubernetes.io/role/elb: "1" + {{- end }} + {{- if eq $subnet.type "public" }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} + {{- end }} + region: {{ $region }} + vpcIdSelector: + matchControllerRef: true + availabilityZone: {{ $subnet.availabilityZone }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $deletionPolicy }} + {{- end }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: RouteTable + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("rt") }} + spec: + forProvider: + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: Route + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("route") }} + spec: + forProvider: + destinationCidrBlock: 0.0.0.0/0 + gatewayIdSelector: + matchControllerRef: true + routeTableIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: MainRouteTableAssociation + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("mrt") }} + spec: + forProvider: + routeTableIdSelector: + matchControllerRef: true + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + {{- range $i, $subnet := $params.subnets }} + --- + kind: RouteTableAssociation + metadata: + labels: + networks.aws.platform.upbound.io/network-id: {{ $params.id }} + annotations: + {{ setResourceNameAnnotation (printf "rta-%s-%s" $subnet.availabilityZone $subnet.type) }} + spec: + forProvider: + routeTableIdSelector: + matchControllerRef: true + subnetIdSelector: + matchControllerRef: true + region: {{ $region }} + matchLabels: + {{- if eq $subnet.type "private" }} + access: private + {{- else }} + access: public + {{- end }} + zone: {{ $subnet.availabilityZone }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $deletionPolicy }} + {{- end }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: SecurityGroup + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("sg") }} + spec: + forProvider: + description: Allow access to databases + name: platform-ref-aws-cluster + vpcIdSelector: + matchControllerRef: true + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: SecurityGroupRule + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("sgrp") }} + spec: + forProvider: + cidrBlocks: + - 0.0.0.0/0 + description: Everywhere + fromPort: 5432 + protocol: tcp + securityGroupIdSelector: + matchControllerRef: true + toPort: 5432 + type: ingress + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: ec2.aws.upbound.io/v1beta1 + kind: SecurityGroupRule + metadata: + labels: + {{- include "networkId" . | nindent 4 }} + annotations: + {{ setResourceNameAnnotation ("sgrm") }} + spec: + forProvider: + cidrBlocks: + - 0.0.0.0/0 + description: Everywhere + fromPort: 3306 + protocol: tcp + securityGroupIdSelector: + matchControllerRef: true + toPort: 3306 + type: ingress + {{- include "region" . | nindent 2 }} + {{- include "providerConfigRef" . }} + {{- include "deletionPolicy" . }} + --- + apiVersion: {{ .observed.composite.resource.apiVersion }} + kind: {{ .observed.composite.resource.kind }} + status: + vpcId: {{ dig "resources" "vpc" "resource" "status" "atProvider" "id" "" $.observed }} + subnetIds: + {{- range $i, $subnet := $params.subnets }} + - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + {{- end }} + publicSubnetIds: + {{- range $i, $subnet := $params.subnets }} + {{- if eq $subnet.type "public" }} + - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + {{- end }} + {{- end }} + privateSubnetIds: + {{- range $i, $subnet := $params.subnets }} + {{- if eq $subnet.type "private" }} + - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + {{- end }} + {{- end }} + securityGroupIds: + - {{ dig "resources" "sg" "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} + - step: automatically-detect-ready-composed-resources + functionRef: + name: function-auto-ready + \ No newline at end of file diff --git a/apis/composition.yaml b/apis/composition.yaml deleted file mode 100644 index be68ca5..0000000 --- a/apis/composition.yaml +++ /dev/null @@ -1,274 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1 -kind: Composition -metadata: - name: example-inline -spec: - compositeTypeRef: - apiVersion: example.crossplane.io/v1beta1 - kind: XR - mode: Pipeline - pipeline: - - step: render-templates - functionRef: - name: function-go-templating - input: - apiVersion: gotemplating.fn.crossplane.io/v1beta1 - kind: GoTemplate - source: Inline - inline: - template: | - {{ $params := .observed.composite.resource.spec.parameters }} - - {{- define "providerConfigRef" }} - providerConfigRef: - name: {{ .observed.composite.resource.spec.parameters.providerConfigName }} - {{- end }} - {{- define "networkId" }} - networks.aws.platform.upbound.io/network-id: {{ .observed.composite.resource.spec.parameters.id }} - {{- end }} - {{- define "region" }} - region: {{ .observed.composite.resource.spec.parameters.region }} - {{- end }} - {{- define "deletionPolicy" }} - deletionPolicy: {{ .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} - {{- end }} - - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: VPC - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("vpc") }} - spec: - forProvider: - cidrBlock: 192.168.0.0/16 - enableDnsHostnames: true - enableDnsSupport: true - tags: - Name: {{ .observed.composite.resource.metadata.name }} - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: InternetGateway - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("igw") }} - spec: - forProvider: - vpcIdSelector: - matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - - {{ $region := .observed.composite.resource.spec.parameters.region }} - {{ $deletionPolicy := .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} - - {{- range $i, $subnet := $params.subnets }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Subnet - metadata: - labels: - zone: {{ $subnet.availabilityZone }} - {{- if eq $subnet.type "private" }} - access: private - {{- else }} - access: public - {{- end }} - networks.aws.platform.upbound.io/network-id: {{ $params.id }} - annotations: - {{ setResourceNameAnnotation (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) }} - spec: - forProvider: - cidrBlock: 192.168.0.0/18 - {{ if eq $subnet.type "public" }} - mapPublicIpOnLaunch: true - {{ end }} - tags: - {{- if eq $subnet.type "private" }} - kubernetes.io/role/internal-elb: "1" - {{- else }} - kubernetes.io/role/elb: "1" - {{- end }} - {{- if eq $subnet.type "public" }} - networks.aws.platform.upbound.io/network-id: {{ $params.id }} - {{- end }} - region: {{ $region }} - vpcIdSelector: - matchControllerRef: true - availabilityZone: {{ $subnet.availabilityZone }} - providerConfigRef: - name: {{ $params.providerConfigName }} - deletionPolicy: {{ $deletionPolicy }} - {{- end }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: RouteTable - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("rt") }} - spec: - forProvider: - vpcIdSelector: - matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: Route - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("route") }} - spec: - forProvider: - destinationCidrBlock: 0.0.0.0/0 - gatewayIdSelector: - matchControllerRef: true - routeTableIdSelector: - matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: MainRouteTableAssociation - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("mrt") }} - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - vpcIdSelector: - matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - {{- range $i, $subnet := $params.subnets }} - --- - kind: RouteTableAssociation - metadata: - labels: - networks.aws.platform.upbound.io/network-id: {{ $params.id }} - annotations: - {{ setResourceNameAnnotation (printf "rta-%s-%s" $subnet.availabilityZone $subnet.type) }} - spec: - forProvider: - routeTableIdSelector: - matchControllerRef: true - subnetIdSelector: - matchControllerRef: true - region: {{ $region }} - matchLabels: - {{- if eq $subnet.type "private" }} - access: private - {{- else }} - access: public - {{- end }} - zone: {{ $subnet.availabilityZone }} - providerConfigRef: - name: {{ $params.providerConfigName }} - deletionPolicy: {{ $deletionPolicy }} - {{- end }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: SecurityGroup - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("sg") }} - spec: - forProvider: - description: Allow access to databases - name: platform-ref-aws-cluster - vpcIdSelector: - matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: SecurityGroupRule - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("sgrp") }} - spec: - forProvider: - cidrBlocks: - - 0.0.0.0/0 - description: Everywhere - fromPort: 5432 - protocol: tcp - securityGroupIdSelector: - matchControllerRef: true - toPort: 5432 - type: ingress - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - --- - apiVersion: ec2.aws.upbound.io/v1beta1 - kind: SecurityGroupRule - metadata: - labels: - {{- include "networkId" . | nindent 4 }} - annotations: - {{ setResourceNameAnnotation ("sgrm") }} - spec: - forProvider: - cidrBlocks: - - 0.0.0.0/0 - description: Everywhere - fromPort: 3306 - protocol: tcp - securityGroupIdSelector: - matchControllerRef: true - toPort: 3306 - type: ingress - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} - --- - apiVersion: {{ .observed.composite.resource.apiVersion }} - kind: {{ .observed.composite.resource.kind }} - status: - vpcId: {{ dig "resources" "vpc" "resource" "status" "atProvider" "id" "" $.observed }} - subnetIds: - {{- range $i, $subnet := $params.subnets }} - - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} - {{- end }} - publicSubnetIds: - {{- range $i, $subnet := $params.subnets }} - {{- if eq $subnet.type "public" }} - - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} - {{- end }} - {{- end }} - privateSubnetIds: - {{- range $i, $subnet := $params.subnets }} - {{- if eq $subnet.type "private" }} - - {{ dig "resources" (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} - {{- end }} - {{- end }} - securityGroupIds: - - {{ dig "resources" "sg" "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} - - step: automatically-detect-ready-composed-resources - functionRef: - name: function-auto-ready - \ No newline at end of file diff --git a/apis/functions.yaml b/apis/functions.yaml deleted file mode 100644 index c482b74..0000000 --- a/apis/functions.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: pkg.crossplane.io/v1beta1 -kind: Function -metadata: - name: function-go-templating -spec: - package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 ---- -apiVersion: pkg.crossplane.io/v1beta1 -kind: Function -metadata: - name: function-auto-ready -spec: - package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.2.1 \ No newline at end of file diff --git a/apis/xr.yaml b/apis/xr.yaml deleted file mode 100644 index 9331f0c..0000000 --- a/apis/xr.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: aws.platform.upbound.io/v1alpha1 -kind: XNetwork -metadata: - name: ref-aws-network -spec: - parameters: - id: platform-ref-aws - region: us-west-2 - deletionPolicy: Delete - providerConfigName: aws-provider-config - subnets: - - availabilityZone: us-west-2a - type: public - cidrBlock: 192.168.0.0/18 - - availabilityZone: us-west-2b - type: public - cidrBlock: 192.168.64.0/18 - - availabilityZone: us-west-2a - type: private - cidrBlock: 192.168.128.0/18 - - availabilityZone: us-west-2b - type: private - cidrBlock: 192.168.192.0/18 diff --git a/examples/function/function.yaml b/examples/function/function.yaml index 3489c37..c482b74 100644 --- a/examples/function/function.yaml +++ b/examples/function/function.yaml @@ -1,6 +1,13 @@ apiVersion: pkg.crossplane.io/v1beta1 kind: Function metadata: - name: crossplane-contrib-function-patch-and-transform + name: function-go-templating spec: - package: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform:v0.2.1 + package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: function-auto-ready +spec: + package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.2.1 \ No newline at end of file diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index 2c15b49..9331f0c 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -6,3 +6,18 @@ spec: parameters: id: platform-ref-aws region: us-west-2 + deletionPolicy: Delete + providerConfigName: aws-provider-config + subnets: + - availabilityZone: us-west-2a + type: public + cidrBlock: 192.168.0.0/18 + - availabilityZone: us-west-2b + type: public + cidrBlock: 192.168.64.0/18 + - availabilityZone: us-west-2a + type: private + cidrBlock: 192.168.128.0/18 + - availabilityZone: us-west-2b + type: private + cidrBlock: 192.168.192.0/18 From 4042453e97030d4fe864cb99b00eff9caf6dc0f7 Mon Sep 17 00:00:00 2001 From: irizzant Date: Fri, 17 May 2024 12:18:03 +0200 Subject: [PATCH 04/15] fix: fix yamllint --- apis/basic/composition.yaml | 7 +++---- apis/definition.yaml | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index be68ca5..7cbd063 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -18,7 +18,7 @@ spec: inline: template: | {{ $params := .observed.composite.resource.spec.parameters }} - + {{- define "providerConfigRef" }} providerConfigRef: name: {{ .observed.composite.resource.spec.parameters.providerConfigName }} @@ -50,7 +50,7 @@ spec: {{- include "region" . | nindent 2 }} {{- include "providerConfigRef" . }} {{- include "deletionPolicy" . }} - + --- apiVersion: ec2.aws.upbound.io/v1beta1 kind: InternetGateway @@ -245,7 +245,7 @@ spec: {{- include "region" . | nindent 2 }} {{- include "providerConfigRef" . }} {{- include "deletionPolicy" . }} - --- + --- apiVersion: {{ .observed.composite.resource.apiVersion }} kind: {{ .observed.composite.resource.kind }} status: @@ -271,4 +271,3 @@ spec: - step: automatically-detect-ready-composed-resources functionRef: name: function-auto-ready - \ No newline at end of file diff --git a/apis/definition.yaml b/apis/definition.yaml index b30fa2f..43e1987 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -58,18 +58,18 @@ spec: - type - cidrBlock default: - - availabilityZone: us-west-2a - type: public - cidrBlock: 192.168.0.0/18 - - availabilityZone: us-west-2b - type: public - cidrBlock: 192.168.64.0/18 - - availabilityZone: us-west-2a - type: private - cidrBlock: 192.168.128.0/18 - - availabilityZone: us-west-2b - type: private - cidrBlock: 192.168.192.0/18 + - availabilityZone: us-west-2a + type: public + cidrBlock: 192.168.0.0/18 + - availabilityZone: us-west-2b + type: public + cidrBlock: 192.168.64.0/18 + - availabilityZone: us-west-2a + type: private + cidrBlock: 192.168.128.0/18 + - availabilityZone: us-west-2b + type: private + cidrBlock: 192.168.192.0/18 required: - deletionPolicy - providerConfigName From 41adeb6b69d673487c51a236c8e7c2a7e654c2b1 Mon Sep 17 00:00:00 2001 From: irizzant Date: Fri, 17 May 2024 13:05:43 +0200 Subject: [PATCH 05/15] chore: Update .gitignore to exclude devbox* files --- .gitignore | 3 ++- devbox.json | 14 ----------- devbox.lock | 69 ----------------------------------------------------- 3 files changed, 2 insertions(+), 84 deletions(-) delete mode 100644 devbox.json delete mode 100644 devbox.lock diff --git a/.gitignore b/.gitignore index 12ef31c..fe34fe6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /.idea *.xpkg -kubeconfig \ No newline at end of file +kubeconfig +devbox* \ No newline at end of file diff --git a/devbox.json b/devbox.json deleted file mode 100644 index 00eb18f..0000000 --- a/devbox.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.10.7/.schema/devbox.schema.json", - "packages": ["crossplane@latest"], - "shell": { - "init_hook": [ - "echo 'Welcome to devbox!' > /dev/null" - ], - "scripts": { - "test": [ - "echo \"Error: no test specified\" && exit 1" - ] - } - } -} diff --git a/devbox.lock b/devbox.lock deleted file mode 100644 index 650efe0..0000000 --- a/devbox.lock +++ /dev/null @@ -1,69 +0,0 @@ -{ - "lockfile_version": "1", - "packages": { - "crossplane@latest": { - "last_modified": "2024-05-13T18:06:16Z", - "resolved": "github:NixOS/nixpkgs/1daef0114a6074be56586f2cf81898ed142e1e44#crossplane", - "source": "devbox-search", - "version": "0.5.8", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/2kf88i0mrgiqqmi5ppvwkjy4rvjg52r8-python3.11-crossplane-0.5.8", - "default": true - }, - { - "name": "dist", - "path": "/nix/store/sp6m4f6lr84xmy89qcxkyxcxqh2k4k09-python3.11-crossplane-0.5.8-dist" - } - ], - "store_path": "/nix/store/2kf88i0mrgiqqmi5ppvwkjy4rvjg52r8-python3.11-crossplane-0.5.8" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/w1y44jk4b4s1qj9rrn0z9ygg4bk7f4fw-python3.11-crossplane-0.5.8", - "default": true - }, - { - "name": "dist", - "path": "/nix/store/wvgsrs83asv7jsq6ld2pp8qgysv3crvw-python3.11-crossplane-0.5.8-dist" - } - ], - "store_path": "/nix/store/w1y44jk4b4s1qj9rrn0z9ygg4bk7f4fw-python3.11-crossplane-0.5.8" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/90mp5kxb7bac37p0p8q4d38wv3djm0wz-python3.11-crossplane-0.5.8", - "default": true - }, - { - "name": "dist", - "path": "/nix/store/hjxshzb4zbj0q8j78krp8vy2v5dz2hia-python3.11-crossplane-0.5.8-dist" - } - ], - "store_path": "/nix/store/90mp5kxb7bac37p0p8q4d38wv3djm0wz-python3.11-crossplane-0.5.8" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/cgva3s7jbz8whz4wd1cqkbzbsdgi067b-python3.11-crossplane-0.5.8", - "default": true - }, - { - "name": "dist", - "path": "/nix/store/6y6l7isyi3ridw2c5h45h8s8wclcxbni-python3.11-crossplane-0.5.8-dist" - } - ], - "store_path": "/nix/store/cgva3s7jbz8whz4wd1cqkbzbsdgi067b-python3.11-crossplane-0.5.8" - } - } - } - } -} From 449f5cf18e2067918efebc31ab27ad27877ff298 Mon Sep 17 00:00:00 2001 From: irizzant Date: Fri, 17 May 2024 21:23:25 +0200 Subject: [PATCH 06/15] chore: Update API definition file with new functions and subnets --- apis/basic/composition.yaml | 14 +++++++++----- crossplane.yaml | 9 ++++++--- examples/network-xr.yaml | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index 7cbd063..9942778 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -1,16 +1,19 @@ apiVersion: apiextensions.crossplane.io/v1 kind: Composition metadata: - name: example-inline + name: xnetworks.aws.platform.upbound.io + labels: + provider: aws + type: basic spec: compositeTypeRef: - apiVersion: example.crossplane.io/v1beta1 - kind: XR + apiVersion: aws.platform.upbound.io/v1alpha1 + kind: XNetwork mode: Pipeline pipeline: - step: render-templates functionRef: - name: function-go-templating + name: crossplane-contrib-function-go-templating input: apiVersion: gotemplating.fn.crossplane.io/v1beta1 kind: GoTemplate @@ -160,6 +163,7 @@ spec: {{- include "deletionPolicy" . }} {{- range $i, $subnet := $params.subnets }} --- + apiVersion: ec2.aws.upbound.io/v1beta1 kind: RouteTableAssociation metadata: labels: @@ -270,4 +274,4 @@ spec: - {{ dig "resources" "sg" "resource" "metadata" "annotations" "crossplane.io/external-name" "" $.observed }} - step: automatically-detect-ready-composed-resources functionRef: - name: function-auto-ready + name: crossplane-contrib-function-auto-ready diff --git a/crossplane.yaml b/crossplane.yaml index 0671704..2bd64ba 100644 --- a/crossplane.yaml +++ b/crossplane.yaml @@ -19,6 +19,9 @@ spec: - provider: xpkg.upbound.io/upbound/provider-aws-ec2 # renovate: datasource=github-releases depName=upbound/provider-aws version: "v1.4.0" - - function: xpkg.upbound.io/crossplane-contrib/function-patch-and-transform - # renovate: datasource=github-releases depName=crossplane-contrib/function-patch-and-transform - version: "v0.5.0" + - function: xpkg.upbound.io/crossplane-contrib/function-auto-ready + # renovate: datasource=github-releases depName=crossplane-contrib/function-auto-ready + version: "v0.2.1" + - function: xpkg.upbound.io/crossplane-contrib/function-go-templating + # renovate: datasource=github-releases depName=crossplane-contrib/function-go-templating + version: "v0.4.1" diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index 9331f0c..e8dbe38 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -7,7 +7,7 @@ spec: id: platform-ref-aws region: us-west-2 deletionPolicy: Delete - providerConfigName: aws-provider-config + providerConfigName: default subnets: - availabilityZone: us-west-2a type: public From 93b5566f15a8c9a4f9ee683bda9d9a3c1f744101 Mon Sep 17 00:00:00 2001 From: irizzant Date: Mon, 20 May 2024 10:23:25 +0200 Subject: [PATCH 07/15] chore: Update API definition file with new functions and subnets --- apis/basic/composition.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index 9942778..5f8d803 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -90,7 +90,7 @@ spec: {{ setResourceNameAnnotation (printf "subnet-%s-%s" $subnet.availabilityZone $subnet.type) }} spec: forProvider: - cidrBlock: 192.168.0.0/18 + cidrBlock: {{ $subnet.cidrBlock }} {{ if eq $subnet.type "public" }} mapPublicIpOnLaunch: true {{ end }} @@ -172,11 +172,11 @@ spec: {{ setResourceNameAnnotation (printf "rta-%s-%s" $subnet.availabilityZone $subnet.type) }} spec: forProvider: + region: {{ $region }} routeTableIdSelector: matchControllerRef: true subnetIdSelector: matchControllerRef: true - region: {{ $region }} matchLabels: {{- if eq $subnet.type "private" }} access: private From ff290869f71d9873b0d2ff0f8772eeadda151220 Mon Sep 17 00:00:00 2001 From: irizzant Date: Mon, 20 May 2024 10:42:11 +0200 Subject: [PATCH 08/15] chore: Update VPC CIDR block in composition.yaml --- apis/basic/composition.yaml | 2 +- apis/definition.yaml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index 5f8d803..43f90b7 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -45,7 +45,7 @@ spec: {{ setResourceNameAnnotation ("vpc") }} spec: forProvider: - cidrBlock: 192.168.0.0/16 + cidrBlock: {{ $params.vpcCidrBlock }} enableDnsHostnames: true enableDnsSupport: true tags: diff --git a/apis/definition.yaml b/apis/definition.yaml index 43e1987..26f2cf6 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -38,6 +38,10 @@ spec: description: Crossplane ProviderConfig to use for provisioning this resources type: string default: default + vpcCidrBlock: + type: string + description: CIDR block for the VPC + default: 192.168.0.0/16 subnets: type: array items: @@ -75,6 +79,8 @@ spec: - providerConfigName - id - region + - subnets + - vpcCidrBlock type: object required: - parameters From 30c0be1d9e281c3e69b82e7e30d912babc35feae Mon Sep 17 00:00:00 2001 From: irizzant Date: Mon, 20 May 2024 10:49:02 +0200 Subject: [PATCH 09/15] fix: remove defaults from network-xr --- examples/network-xr.yaml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index e8dbe38..7c09278 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -5,19 +5,4 @@ metadata: spec: parameters: id: platform-ref-aws - region: us-west-2 - deletionPolicy: Delete - providerConfigName: default - subnets: - - availabilityZone: us-west-2a - type: public - cidrBlock: 192.168.0.0/18 - - availabilityZone: us-west-2b - type: public - cidrBlock: 192.168.64.0/18 - - availabilityZone: us-west-2a - type: private - cidrBlock: 192.168.128.0/18 - - availabilityZone: us-west-2b - type: private - cidrBlock: 192.168.192.0/18 + region: us-west-2 \ No newline at end of file From 3319a7a187d8d140ab7d517a74c8e3bbbe1f1328 Mon Sep 17 00:00:00 2001 From: irizzant Date: Mon, 20 May 2024 12:50:19 +0200 Subject: [PATCH 10/15] feat: update to v1alpha2 --- apis/basic/composition.yaml | 2 +- apis/definition.yaml | 2 +- examples/network-xr.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index 43f90b7..a0e3f83 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -7,7 +7,7 @@ metadata: type: basic spec: compositeTypeRef: - apiVersion: aws.platform.upbound.io/v1alpha1 + apiVersion: aws.platform.upbound.io/v1alpha2 kind: XNetwork mode: Pipeline pipeline: diff --git a/apis/definition.yaml b/apis/definition.yaml index 26f2cf6..7657235 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -8,7 +8,7 @@ spec: kind: XNetwork plural: xnetworks versions: - - name: v1alpha1 + - name: v1alpha2 served: true referenceable: true schema: diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index 7c09278..df5cd5e 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -1,4 +1,4 @@ -apiVersion: aws.platform.upbound.io/v1alpha1 +apiVersion: aws.platform.upbound.io/v1alpha2 kind: XNetwork metadata: name: ref-aws-network From 269a1f63e0ca9999ea4ad203354d5b0a459dd534 Mon Sep 17 00:00:00 2001 From: irizzant Date: Mon, 20 May 2024 14:16:45 +0200 Subject: [PATCH 11/15] feat: keep using v1alpha1 --- apis/basic/composition.yaml | 2 +- apis/definition.yaml | 2 +- examples/network-xr.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apis/basic/composition.yaml b/apis/basic/composition.yaml index a0e3f83..43f90b7 100644 --- a/apis/basic/composition.yaml +++ b/apis/basic/composition.yaml @@ -7,7 +7,7 @@ metadata: type: basic spec: compositeTypeRef: - apiVersion: aws.platform.upbound.io/v1alpha2 + apiVersion: aws.platform.upbound.io/v1alpha1 kind: XNetwork mode: Pipeline pipeline: diff --git a/apis/definition.yaml b/apis/definition.yaml index 7657235..26f2cf6 100644 --- a/apis/definition.yaml +++ b/apis/definition.yaml @@ -8,7 +8,7 @@ spec: kind: XNetwork plural: xnetworks versions: - - name: v1alpha2 + - name: v1alpha1 served: true referenceable: true schema: diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index df5cd5e..7c09278 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -1,4 +1,4 @@ -apiVersion: aws.platform.upbound.io/v1alpha2 +apiVersion: aws.platform.upbound.io/v1alpha1 kind: XNetwork metadata: name: ref-aws-network From 5c148ad40e8717d28272afa7cb4743da00c87fcf Mon Sep 17 00:00:00 2001 From: irizzant Date: Tue, 21 May 2024 16:10:33 +0200 Subject: [PATCH 12/15] chore: Update API definition file with new functions and subnets --- apis/{basic => }/composition.yaml | 2 +- .../{function/function.yaml => functions.yaml} | 4 ++-- examples/network-xr.yaml | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) rename apis/{basic => }/composition.yaml (99%) rename examples/{function/function.yaml => functions.yaml} (74%) diff --git a/apis/basic/composition.yaml b/apis/composition.yaml similarity index 99% rename from apis/basic/composition.yaml rename to apis/composition.yaml index 43f90b7..55d60f6 100644 --- a/apis/basic/composition.yaml +++ b/apis/composition.yaml @@ -70,7 +70,7 @@ spec: {{- include "providerConfigRef" . }} {{- include "deletionPolicy" . }} - {{ $region := .observed.composite.resource.spec.parameters.region }} + {{ $region := $params.region }} {{ $deletionPolicy := .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} {{- range $i, $subnet := $params.subnets }} diff --git a/examples/function/function.yaml b/examples/functions.yaml similarity index 74% rename from examples/function/function.yaml rename to examples/functions.yaml index c482b74..779f6df 100644 --- a/examples/function/function.yaml +++ b/examples/functions.yaml @@ -1,13 +1,13 @@ apiVersion: pkg.crossplane.io/v1beta1 kind: Function metadata: - name: function-go-templating + name: crossplane-contrib-function-go-templating spec: package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.4.1 --- apiVersion: pkg.crossplane.io/v1beta1 kind: Function metadata: - name: function-auto-ready + name: crossplane-contrib-function-auto-ready spec: package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.2.1 \ No newline at end of file diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index 7c09278..70304a6 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -5,4 +5,18 @@ metadata: spec: parameters: id: platform-ref-aws - region: us-west-2 \ No newline at end of file + region: us-west-2 + vpcCidrBlock: 192.168.0.0/16 + subnets: + - availabilityZone: us-west-2a + type: public + cidrBlock: 192.168.0.0/18 + - availabilityZone: us-west-2b + type: public + cidrBlock: 192.168.64.0/18 + - availabilityZone: us-west-2a + type: private + cidrBlock: 192.168.128.0/18 + - availabilityZone: us-west-2b + type: private + cidrBlock: 192.168.192.0/18 \ No newline at end of file From 6a255acfd4f4666fa0295dcdb9f9f5162886c6d6 Mon Sep 17 00:00:00 2001 From: irizzant Date: Wed, 22 May 2024 09:28:18 +0200 Subject: [PATCH 13/15] chore: Update deletion policy in composition.yaml --- apis/composition.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/composition.yaml b/apis/composition.yaml index 55d60f6..b6bbdcc 100644 --- a/apis/composition.yaml +++ b/apis/composition.yaml @@ -71,7 +71,7 @@ spec: {{- include "deletionPolicy" . }} {{ $region := $params.region }} - {{ $deletionPolicy := .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} + {{ $deletionPolicy := $params.deletionPolicy | default "Delete" }} {{- range $i, $subnet := $params.subnets }} --- From 441df43de2232921d7af22e896e21de338b4c665 Mon Sep 17 00:00:00 2001 From: irizzant Date: Thu, 23 May 2024 16:03:42 +0200 Subject: [PATCH 14/15] refactor: don't use include and define --- apis/composition.yaml | 86 ++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 46 deletions(-) diff --git a/apis/composition.yaml b/apis/composition.yaml index b6bbdcc..521a1c7 100644 --- a/apis/composition.yaml +++ b/apis/composition.yaml @@ -22,25 +22,11 @@ spec: template: | {{ $params := .observed.composite.resource.spec.parameters }} - {{- define "providerConfigRef" }} - providerConfigRef: - name: {{ .observed.composite.resource.spec.parameters.providerConfigName }} - {{- end }} - {{- define "networkId" }} - networks.aws.platform.upbound.io/network-id: {{ .observed.composite.resource.spec.parameters.id }} - {{- end }} - {{- define "region" }} - region: {{ .observed.composite.resource.spec.parameters.region }} - {{- end }} - {{- define "deletionPolicy" }} - deletionPolicy: {{ .observed.composite.resource.spec.parameters.deletionPolicy | default "Delete" }} - {{- end }} - apiVersion: ec2.aws.upbound.io/v1beta1 kind: VPC metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("vpc") }} spec: @@ -50,25 +36,27 @@ spec: enableDnsSupport: true tags: Name: {{ .observed.composite.resource.metadata.name }} - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} --- apiVersion: ec2.aws.upbound.io/v1beta1 kind: InternetGateway metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("igw") }} spec: forProvider: vpcIdSelector: matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} {{ $region := $params.region }} {{ $deletionPolicy := $params.deletionPolicy | default "Delete" }} @@ -116,22 +104,23 @@ spec: kind: RouteTable metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("rt") }} spec: forProvider: vpcIdSelector: matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} --- apiVersion: ec2.aws.upbound.io/v1beta1 kind: Route metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("route") }} spec: @@ -141,15 +130,16 @@ spec: matchControllerRef: true routeTableIdSelector: matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} --- apiVersion: ec2.aws.upbound.io/v1beta1 kind: MainRouteTableAssociation metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("mrt") }} spec: @@ -158,9 +148,10 @@ spec: matchControllerRef: true vpcIdSelector: matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} {{- range $i, $subnet := $params.subnets }} --- apiVersion: ec2.aws.upbound.io/v1beta1 @@ -193,7 +184,7 @@ spec: kind: SecurityGroup metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("sg") }} spec: @@ -202,15 +193,16 @@ spec: name: platform-ref-aws-cluster vpcIdSelector: matchControllerRef: true - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} --- apiVersion: ec2.aws.upbound.io/v1beta1 kind: SecurityGroupRule metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("sgrp") }} spec: @@ -224,15 +216,16 @@ spec: matchControllerRef: true toPort: 5432 type: ingress - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} --- apiVersion: ec2.aws.upbound.io/v1beta1 kind: SecurityGroupRule metadata: labels: - {{- include "networkId" . | nindent 4 }} + networks.aws.platform.upbound.io/network-id: {{ $params.id }} annotations: {{ setResourceNameAnnotation ("sgrm") }} spec: @@ -246,9 +239,10 @@ spec: matchControllerRef: true toPort: 3306 type: ingress - {{- include "region" . | nindent 2 }} - {{- include "providerConfigRef" . }} - {{- include "deletionPolicy" . }} + region: {{ $params.region }} + providerConfigRef: + name: {{ $params.providerConfigName }} + deletionPolicy: {{ $params.deletionPolicy | default "Delete" }} --- apiVersion: {{ .observed.composite.resource.apiVersion }} kind: {{ .observed.composite.resource.kind }} From 562d7cd1e49fc091d3a821fd4489cae2966b50b2 Mon Sep 17 00:00:00 2001 From: irizzant Date: Fri, 24 May 2024 09:54:55 +0200 Subject: [PATCH 15/15] chore: update crossplane render command to use correct file paths and names --- Makefile | 2 +- apis/composition.yaml | 1 - examples/network-xr.yaml | 28 ++++++++++++++-------------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 5c9e7b2..6b87d61 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ uptest: $(UPTEST) $(KUBECTL) $(KUTTL) e2e: build controlplane.up local.xpkg.deploy.configuration.$(PROJECT_NAME) uptest render: - crossplane beta render examples/network-xr.yaml apis/basic/composition.yaml examples/function/function.yaml -r + crossplane beta render examples/network-xr.yaml apis/composition.yaml examples/functions.yaml -r yamllint: @$(INFO) running yamllint diff --git a/apis/composition.yaml b/apis/composition.yaml index 521a1c7..aca0e24 100644 --- a/apis/composition.yaml +++ b/apis/composition.yaml @@ -4,7 +4,6 @@ metadata: name: xnetworks.aws.platform.upbound.io labels: provider: aws - type: basic spec: compositeTypeRef: apiVersion: aws.platform.upbound.io/v1alpha1 diff --git a/examples/network-xr.yaml b/examples/network-xr.yaml index 70304a6..3a5000d 100644 --- a/examples/network-xr.yaml +++ b/examples/network-xr.yaml @@ -6,17 +6,17 @@ spec: parameters: id: platform-ref-aws region: us-west-2 - vpcCidrBlock: 192.168.0.0/16 - subnets: - - availabilityZone: us-west-2a - type: public - cidrBlock: 192.168.0.0/18 - - availabilityZone: us-west-2b - type: public - cidrBlock: 192.168.64.0/18 - - availabilityZone: us-west-2a - type: private - cidrBlock: 192.168.128.0/18 - - availabilityZone: us-west-2b - type: private - cidrBlock: 192.168.192.0/18 \ No newline at end of file + vpcCidrBlock: 192.168.0.0/16 + subnets: + - availabilityZone: us-west-2a + type: public + cidrBlock: 192.168.0.0/18 + - availabilityZone: us-west-2b + type: public + cidrBlock: 192.168.64.0/18 + - availabilityZone: us-west-2a + type: private + cidrBlock: 192.168.128.0/18 + - availabilityZone: us-west-2b + type: private + cidrBlock: 192.168.192.0/18