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

Need AppSync API attributes to include endpoint URL #4879

Closed
macbutch opened this issue Jun 19, 2018 · 12 comments · Fixed by #6138
Closed

Need AppSync API attributes to include endpoint URL #4879

macbutch opened this issue Jun 19, 2018 · 12 comments · Fixed by #6138
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/appsync Issues and PRs that pertain to the appsync service.
Milestone

Comments

@macbutch
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Currently the aws_appsync_graphql_api resource only exports arn and id as attributes (no others). It would be very very useful to me if the endpoint URL was also exported (like CloudFormation does).

New or Affected Resource(s)

  • aws_appsync_graphql_api

Potential Terraform Configuration

No change is proposed to the resource definition, the existing example is fine:

resource "aws_appsync_graphql_api" "example" {
  authentication_type = "API_KEY"
  name = "example"
}

However this change would also enable these usages:

output "api_endpoint" {
  value = "${aws_appsync_graphql_api.example.api_endpoint}"
}

and:

resource "aws_lambda_function" "iot_event" {
  ...

  environment {
    variables {
      GRAPHQL_ENDPOINT = "${aws_appsync_graphql_api.example.api_endpoint}"
    }
  }
}

References

@macbutch
Copy link
Contributor Author

I took a quick look at what would be required to do this and it's not as simple as I'd expected. The API returns a map of URLs which I imagine would contain a single entry with the URL that I'm interested in. I don't know under what circumstances it might contain something else as well.

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/appsync Issues and PRs that pertain to the appsync service. labels Jun 21, 2018
@joseph-wortmann
Copy link

Is there any update on this? It's almost useless to create an API endpoint and then not expose the endpoint URI.

It appears that the URI required is under the "GRAPHQL" key in the map that you referenced @macbutch .

@macbutch
Copy link
Contributor Author

Thanks @joseph-wortmann. I can't see where the keys in that map are documented - did you figure this out from calling the API and inspecting the results or am I just not reading the docs right? I think we'd be interested in at least starting working on a pull request it's not very high priority for us (yet) but it's becoming more and more important.

@joseph-wortmann
Copy link

@macbutch I figured it out by calling the CLI and observing the results compared against the console. Honestly, I didn't even go to the docs. As we all know, sometimes they can be a little less than they should. Maybe it is AWS's way of testing us.

@joseph-wortmann
Copy link

I'd be happy to help with the PR, but Go is like reading greek for me. I can't read greek either

@joseph-wortmann
Copy link

joseph-wortmann commented Aug 30, 2018

For those that need to access the endpoint in TF, here is a script that will get it for you in an external data resource. Usage in TF is below.

data "external" "appsync_graphql_endpoint" {
  program = [
    "bash",
    "${path.module}/scripts/get-graphql-endpoint.sh"
  ]
  query {
    api_id = "${aws_appsync_graphql_api.ff_graphql.id}"
  }
}

Use the external like the following:
${data.external.appsync_graphql_endpoint.result["endpoint"]}

Change the .txt extension to .sh (won't let me upload a script)
get-graphql-endpoint.txt

@joseph-wortmann
Copy link

I'm not a patient person, so I created a module that does the above for you. Feel free to use until the resource publishes the endpoint.

https://registry.terraform.io/modules/QuiNovas/appsync-graphql-api-endpoint/aws/1.0.3

@eugene-manuilov
Copy link

Thanks, @macbutch and @joseph-wortmann! I would also like to see this feature implemented. Additionally, I would like to see this information in the .tfstate file because I use it to grab information about the infrastructure in my js app.

@bflad
Copy link
Contributor

bflad commented Oct 12, 2018

Pull request submitted which includes the endpoint via aws_appsync_graphql_api.example.uris["GRAPHQL"]: #6138

@bflad bflad added this to the v1.41.0 milestone Oct 18, 2018
@bflad
Copy link
Contributor

bflad commented Oct 18, 2018

The above feature has been merged and will release with version 1.41.0 of the AWS provider, likely later today. 👍

@bflad
Copy link
Contributor

bflad commented Oct 18, 2018

This has been released in version 1.41.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 2, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/appsync Issues and PRs that pertain to the appsync service.
Projects
None yet
4 participants