crossplane-contrib / provider-upjet-azure

Official Azure Provider for Crossplane by Upbound.
Apache License 2.0
53 stars 69 forks source link

Unable to change azure resource name in compositions #623

Open pp-csievering opened 5 months ago

pp-csievering commented 5 months ago

What happened?

When creating a virtual network and subnets using a composition, I am unable to change the name of the resources. This needs to be done I need to name my the subnets "AzureFirewallSubnet" and "GatewaySubnet". I've tried using the "crossplane.io/external-name" annotation without success.

How can we reproduce it?

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: compositevirtualnetworks.azure.networking.example.io
  labels:
    provider: provider-azure
    configuration: standard
spec:
  writeConnectionSecretsToNamespace: crossplane-system
  compositeTypeRef:
    apiVersion: networking.example.io/v1alpha1
    kind: CompositeVirtualNetwork
  resources:
  - name: azure-vnet
    base:
      apiVersion: network.azure.upbound.io/v1beta1
      kind: VirtualNetwork
      metadata:
        annotations:
          crossplane.io/api-id: upbound/v1beta1
        labels:
          crossplane.io/rg-name: crossplane-demo-rg
          crossplane.io/vnet-name: crossplane-vnet
          crossplane.io/type: azure-virtual-network
      spec:
        providerConfigRef:
          name: provider-config-azure
        forProvider:
          description: An azure virtual network
    patches:
    - fromFieldPath: spec.parameters.rgName
      toFieldPath: spec.forProvider.resourceGroupName
    - fromFieldPath: spec.parameters.location
      toFieldPath: spec.forProvider.location
      transforms:
        - type: map
          map:
            northeurope: North Europe
            westeurope: West Europe
    - type: CombineFromComposite
      combine:
        variables:
        - fromFieldPath: spec.parameters.networkCidr
        strategy: string
        string:
          fmt: "10.%d.0.0/16"
      toFieldPath: spec.forProvider.addressSpace[0]
      policy:
        fromFieldPath: Required
  - name: azure-subnet-private-endpoints
    base:
      apiVersion: network.azure.upbound.io/v1beta1
      kind: Subnet
      metadata:
        labels:
          crossplane.io/type: azure-virtual-subnet
          crossplane.io/subnet-for: private-endpoints
        annotations:
          crossplane.io/external-name: private-endpoints
        name: private-endpoints
      spec:
        providerConfigRef:
          name: provider-config-azure
        forProvider:
          virtualNetworkNameSelector:
            matchControllerRef: true
            matchLabels:
              crossplane.io/vnet-name: crossplane-vnet
              crossplane.io/type: azure-virtual-network
          privateEndpointNetworkPoliciesEnabled: true
    patches:
    - fromFieldPath: spec.parameters.rgName
      toFieldPath: spec.forProvider.resourceGroupName
    - type: CombineFromComposite
      combine:
        variables:
        - fromFieldPath: spec.parameters.networkCidr
        strategy: string
        string:
          fmt: "10.%d.1.0/24"
      toFieldPath: spec.forProvider.addressPrefixes[0]
      policy:
        fromFieldPath: Required
  - name: azure-subnet-nodes
    base:
      apiVersion: network.azure.upbound.io/v1beta1
      kind: Subnet
      metadata:
        labels:
          crossplane.io/type: azure-virtual-subnet
          crossplane.io/subnet-for: nodes
      spec:
        providerConfigRef:
          name: provider-config-azure
        forProvider:
          virtualNetworkNameSelector:
            matchControllerRef: true
            matchLabels:
              crossplane.io/vnet-name: crossplane-vnet
              crossplane.io/type: azure-virtual-network
    patches:
    - fromFieldPath: spec.parameters.rgName
      toFieldPath: spec.forProvider.resourceGroupName
    - type: CombineFromComposite
      combine:
        variables:
        - fromFieldPath: spec.parameters.networkCidr
        strategy: string
        string:
          fmt: "10.%d.2.0/24"
      toFieldPath: spec.forProvider.addressPrefixes[0]
      policy:
        fromFieldPath: Required
  - name: azure-subnet-api-server
    base:
      apiVersion: network.azure.upbound.io/v1beta1
      kind: Subnet
      metadata:
        labels:
          crossplane.io/type: azure-virtual-subnet
          crossplane.io/subnet-for: api-server
      spec:
        providerConfigRef:
          name: provider-config-azure
        forProvider:
          delegation:
          - name: api-server-vnet-injection
            serviceDelegation:
            - name: Microsoft.ContainerService/managedClusters
          virtualNetworkNameSelector:
            matchControllerRef: true
            matchLabels:
              crossplane.io/vnet-name: crossplane-vnet
              crossplane.io/type: azure-virtual-network
    patches:
    - fromFieldPath: spec.parameters.rgName
      toFieldPath: spec.forProvider.resourceGroupName
    - type: CombineFromComposite
      combine:
        variables:
        - fromFieldPath: spec.parameters.networkCidr
        strategy: string
        string:
          fmt: "10.%d.3.0/24"
      toFieldPath: spec.forProvider.addressPrefixes[0]
      policy:
        fromFieldPath: Required
  - name: azure-resource-group
    base:
      apiVersion: azure.upbound.io/v1beta1
      kind: ResourceGroup
      metadata:
        name: example-resources
      spec:
        providerConfigRef:
          name: provider-config-azure
        forProvider:
          location: "West Europe"
          tags:
            provisioner: crossplane
    patches:
      - fromFieldPath: "spec.parameters.location"
        toFieldPath: spec.forProvider.location
      - fromFieldPath: spec.parameters.rgName
        toFieldPath: metadata.name

What environment did it happen in?

pp-csievering commented 5 months ago

When applying the provided composition image

github-actions[bot] commented 2 months ago

This provider repo does not have enough maintainers to address every issue. Since there has been no activity in the last 90 days it is now marked as stale. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.