Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[apigatewayv1] Inability to Use parentRef.from.name for Root Path Resource Creation in RestAPI #2359

Open
avishaig1986 opened this issue Feb 26, 2025 · 1 comment
Labels
needs-investigation Indicates an issue needs some investigation. service/apigateway Indicates issues or PRs that are related to apigateway-controller.

Comments

@avishaig1986
Copy link

avishaig1986 commented Feb 26, 2025

Describe the bug
api gateway v1 - https://github.com/aws-controllers-k8s/apigateway-controller

When using API Gateway V1 controller, there is a limitation when attempting to create a Resource whose parent is the root path (/). This issue arises because the parentRef.from.name parameter, which is intended to reference the parent resource by name, is restricted to only recognize Resource names. However, the root path (/) is associated with the RestAPI rather than a Resource, making it impossible to use parentRef.from.name to reference it directly.

As a result, when creating a Resource with the root path as its parent, users must manually retrieve the .status.rootResourceID of the RestAPI after its creation. This additional step is necessary to obtain the root resource ID, which is then used in the ParentID field for creating the Resource.

Steps to reproduce
Attempt to apply the following yaml to the cluster:

apiVersion: apigateway.services.k8s.aws/v1alpha1
kind: RestAPI
metadata:
  name: api-gateway-name
spec:
  name: api-gateway-name
  description: "api-gateway-description"
  endpointConfiguration: 
    types:
      - PRIVATE
---
apiVersion: apigateway.services.k8s.aws/v1alpha1
kind: Resource
metadata:
  name: my-resource
spec:
  restAPIID: dev-hcp.export-root-resource-id
  restAPIRef:
    from:
      name: api-gateway-name
  parentRef:
    from:
      name: api-gateway-name #cannot use the name of a RestAPI , only name of another Resource

Expected outcome
It should be allowed to use the name of the RestAPI in the Resource parentRef.from.name , or have another parameter in Resource such as restApiParentRef.from.name for example

Actual outcome
The following error message appears:
resources.apigateway.services.k8s.aws "example-restapi-name" not found

conditions:
  - lastTransitionTime: 2025-02-26T10:24:40Z
    message: Reference resolution failed
    reason: resources.apigateway.services.k8s.aws "example-restapi-name" not found
    status: Unknown
    type: ACK.ReferencesResolved

Environment

  • EKS Kubernetes version - 1.31
  • AWS service targeted - Lambda Functions
@michaelhtm michaelhtm added needs-investigation Indicates an issue needs some investigation. service/apigateway Indicates issues or PRs that are related to apigateway-controller. labels Feb 26, 2025
@denzhel
Copy link

denzhel commented Mar 5, 2025

Same here, it only works if I provide the parentID:

apiVersion: apigateway.services.k8s.aws/v1alpha1
kind: Resource
metadata:
  name: bp-aws-ack-poc-parent-resource
spec:
  #parentRef:
  #  from:
  #    name: bp-aws-ack-poc
  parentID: 123123abc
  restAPIRef:
    from:
      name: bp-aws-ack-poc
  pathPart: bp-aws-ack-poc

If I uncomment the parentRef and comment ID it errors:

resources.apigateway.services.k8s.aws "bp-aws-ack-poc" not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation Indicates an issue needs some investigation. service/apigateway Indicates issues or PRs that are related to apigateway-controller.
Projects
None yet
Development

No branches or pull requests

3 participants