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

Add authorization_config to http_config for aws_appsync_datasource #12721

Closed
maddijoyce opened this issue Apr 7, 2020 · 3 comments · Fixed by #22411
Closed

Add authorization_config to http_config for aws_appsync_datasource #12721

maddijoyce opened this issue Apr 7, 2020 · 3 comments · Fixed by #22411
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

@maddijoyce
Copy link

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 other comments that do not add relevant new information or questions, 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

The HTTP appsync datasource can have an additional config causing all requests to be signed and opening up access to a much wider range of aws services which use http endpoints - this is setup by adding an authorization config to the endpoint. Would be great to support this in terraform.

New or Affected Resource(s)

  • aws_appsync_datasource

Potential Terraform Configuration

resource "aws_appsync_datasource" "example" {
  api_id           = "${aws_appsync_graphql_api.example.id}"
  name             = "tf_appsync_example"
  service_role_arn = "${aws_iam_role.example.arn}"
  type             = "HTTP"

  http_config {
    endpoint = "https://s3.amazonaws.com"
    
    authorization_config {
      authorization_type = "AWS_IAM"
      aws_iam_config {
        signing_region = "ap-southeast-2"
        signing_service_name = "s3"
      }
    }
  }
}

References

@maddijoyce maddijoyce added the enhancement Requests to existing resources that expand the functionality or scope. label Apr 7, 2020
@ghost ghost added the service/appsync Issues and PRs that pertain to the appsync service. label Apr 7, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 7, 2020
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Aug 6, 2020
@jakubknejzlik
Copy link
Contributor

jakubknejzlik commented Feb 27, 2021

I know it seems to be getting close, but in case anybody is struggling with this, here's workaround using aws_cloudformation_stack...maybe it helps to save some time :).

resource "aws_appsync_graphql_api" "example" {
  name                = "example"
  schema = <<EOF
...
type Mutation {
  # returns execution name directly
  startExecution: ID! 
}
  EOF
}

resource "aws_cloudformation_stack" "example" {
  name          = "AppSyncSFNDataSource"
  template_body = <<STACK
Resources:
  StepFunctionsHttpDataSource:
      Type: AWS::AppSync::DataSource
      Properties:
        ApiId: ${aws_appsync_graphql_api.example.id}
        Name: SFNDataSourceName
        Type: HTTP
        # IAM role defined elsewhere in AWS CloudFormation template
        ServiceRoleArn: ${aws_iam_role.example.arn}
        HttpConfig:
          Endpoint: !Sub https://states.$${AWS::Region}.amazonaws.com/
          AuthorizationConfig:
            AuthorizationType: AWS_IAM
            AwsIamConfig:
              SigningRegion: !Ref AWS::Region
              SigningServiceName: states
Outputs:
  name: 
    Value: SFNDataSourceName
STACK
}

resource "aws_appsync_resolver" "put-table" {
  api_id      = aws_appsync_graphql_api.main.id
  field       = "exampleField"
  type        = "Mutation"
  data_source = aws_cloudformation_stack.example.outputs.name

  request_template = <<EOF
$util.qr($ctx.stash.put("executionId", $util.autoId()))

{
  "version": "2018-05-29",
  "method": "POST",
  "resourcePath": "/",
  "params": {
    "headers": {
      "content-type": "application/x-amz-json-1.0",
      "x-amz-target":"AWSStepFunctions.StartExecution"
    },
    "body": {
      "stateMachineArn": "${aws_sfn_state_machine.my-state-machine.arn}",
      "name": "$ctx.stash.executionId",
      "input": "{\"blah\":\"foo\"}"
    }
  }
}
EOF

  response_template = <<EOF
"$ctx.stash.executionId"
EOF
}

@github-actions
Copy link

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2022
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
3 participants