crossplane-contrib / provider-jet-aws

AWS Provider for Crossplane that is built with Terrajet.
https://crossplane.io
Apache License 2.0
37 stars 30 forks source link

Can't create RouteTable #184

Closed wilhelmi closed 2 years ago

wilhelmi commented 2 years ago

Failed to create a RouteTable, can't find a combination that works.

        apiVersion: ec2.aws.jet.crossplane.io/v1alpha2
        kind: RouteTable
        spec:
          forProvider:
            route:
             - cidrBlock: "0.0.0.0/0"
                carrierGatewayId: null
                destinationIpv6CidrBlock: null
                destinationPrefixListId: null
                egressOnlyGatewayId: null
                instanceId: null
                ipv6CidrBlock: null
                localGatewayId: null
                natGatewayId: null
                networkInterfaceId: null
                transitGatewayId: null
                vpcEndpointId: null
                vpcPeeringConnectionId: null
      patches:
        - fromFieldPath: status.gatewayId
          toFieldPath: spec.forProvider.route[0].gatewayId

Crossplane 1.7.0 jet-aws 0.4.0-preview

Error message:

Incorrect attribute value type: Inappropriate value for attribute
"route": element 0: attributes "carrier_gateway_id",
"destination_prefix_list_id", "egress_only_gateway_id", "gateway_id",
"instance_id", "ipv6_cidr_block", "local_gateway_id", "nat_gateway_id",
"network_interface_id", "transit_gateway_id", "vpc_endpoint_id", and
"vpc_peering_connection_id" are required.: File name: main.tf.json

Gateway Id is patched in to the correct value.

Reference to potentially relevant TF issues: https://github.com/hashicorp/terraform-provider-aws/issues/8786#issuecomment-496935442 https://stackoverflow.com/questions/69689262/inappropriate-value-for-attribute-route-element-0-attributes

andrzej-natzka commented 2 years ago

I have similar issue.

Part of my composition:

  - name: ec2-rt
    base:
      apiVersion: ec2.aws.jet.crossplane.io/v1alpha2
      kind: RouteTable
      spec:
        forProvider:
          vpcidSelector:
            matchControllerRef: true
        providerConfigRef:
          name: aws-jet-provider
    patches:
    - type: PatchSet
      patchSetName: region
    - fromFieldPath: spec.id
      toFieldPath: metadata.name
      transforms:
      - type: string
        string:
          fmt: "%s-rt"

  - name: ec2-rt-route
    base: 
      apiVersion: ec2.aws.jet.crossplane.io/v1alpha2
      kind: Route
      spec:
        forProvider:
          routeTableIdSelector:
            matchControllerRef: true 
          destinationCidrBlock: 0.0.0.0/0 
        providerConfigRef:
          name: aws-jet-provider          
    patches:
    - type: PatchSet
      patchSetName: region
    - fromFieldPath: spec.id
      toFieldPath: metadata.name
      transforms:
      - type: string
        string:
          fmt: "%s-route"
    - fromFieldPath: status.gatewayid
      toFieldPath: spec.forProvider.gatewayId

  - name: ec2-rt-assoc-a
    base:
      apiVersion: ec2.aws.jet.crossplane.io/v1alpha2
      kind: RouteTableAssociation
      spec:
        forProvider:
          routeTableIdSelector:
            matchControllerRef: true
          subnetIdSelector:
            matchControllerRef: true
            matchLabels:
              access: public
        providerConfigRef:
          name: aws-jet-provider
    patches:
    - type: PatchSet
      patchSetName: region
    - type: PatchSet
      patchSetName: route-zone-1
    - fromFieldPath: spec.id
      toFieldPath: metadata.name
      transforms:
      - type: string
        string:
          fmt: "%s-rta-a"       

Status after applying:

NAME                                             READY   SYNCED   EXTERNAL-NAME                       AGE
route.ec2.aws.jet.crossplane.io/xpjeteks-route   True    True     r-rtb-xxx   96m
routetable.ec2.aws.jet.crossplane.io/xpjeteks-rt   True    False    rtb-01a988bb8878868bc   96m
routetableassociation.ec2.aws.jet.crossplane.io/xpjeteks-rta-a   True    True     rtbassoc-0ef8731d6bcb4903f   96m

$ k describe routetable.ec2.aws.jet.crossplane.io/xpjeteks-rt
Events:
  Type     Reason                         Age                      From                                                         Message
  ----     ------                         ----                     ----                                                         -------
  Warning  CannotObserveExternalResource  2m57s (x992 over 3h24m)  managed/ec2.aws.jet.crossplane.io/v1alpha2, kind=routetable  cannot run refresh: refresh failed: Incorrect attribute value type: Inappropriate value for attribute "route": element 0: attributes "carrier_gateway_id", "destination_prefix_list_id", "egress_only_gateway_id", "instance_id", "ipv6_cidr_block", "local_gateway_id", "nat_gateway_id", "network_interface_id", "transit_gateway_id", "vpc_endpoint_id", and "vpc_peering_connection_id" are required.: File name: main.tf.json
haarchri commented 2 years ago

added a basic example in: https://github.com/crossplane-contrib/provider-jet-aws/pull/197 does this help ?