Skip to content

Commit

Permalink
update cloudwatch_event_target website with appsync_target attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoltan Tudlik committed Jun 10, 2024
1 parent ba30caa commit c93fffa
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .changelog/37773.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
```release-note:enhancement
resource/aws_cloudwatch_event_target: Add appsync_target argument
resource/aws_cloudwatch_event_target: Add `appsync_target` argument
```
100 changes: 100 additions & 0 deletions website/docs/r/cloudwatch_event_target.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,101 @@ resource "aws_cloudwatch_event_target" "example" {
}
```

### AppSync Usage

```terraform
resource "aws_cloudwatch_event_rule" "invoke_appsync_mutation" {
name = "invoke-appsync-mutation"
description = "schedule_batch_test"
schedule_expression = "rate(5 minutes)"
}
resource "aws_cloudwatch_event_target" "invoke_appsync_mutation" {
arn = replace(aws_appsync_graphql_api.graphql-api.arn, "apis", "endpoints/graphql-api")
rule = aws_cloudwatch_event_rule.invoke_appsync_mutation.id
role_arn = aws_iam_role.appsync_mutation_role.arn
input_transformer {
input_paths = {
input = "$.detail.input"
}
input_template = <<EOF
{
"input": <input>
}
EOF
}
appsync_target {
graphql_operation = "mutation TestMutation($input:MutationInput!){testMutation(input: $input) {test}}"
}
}
resource "aws_iam_role" "appsync_mutation_role" {
name = "appsync-mutation-role"
assume_role_policy = data.aws_iam_policy_document.appsync_mutation_role_trust.json
}
data "aws_iam_policy_document" "appsync_mutation_role_trust" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["events.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "appsync_mutation_role_policy_document" {
statement {
actions = ["appsync:GraphQL"]
effect = "Allow"
resources = [
aws_appsync_graphql_api.graphql-api.arn
]
}
}
resource "aws_iam_policy" "appsync_mutation_role_policy" {
name = "appsync-mutation-role-policy"
policy = data.aws_iam_policy_document.appsync_mutation_role_policy_document.json
}
resource "aws_iam_role_policy_attachment" "appsync_mutation_role_attachment" {
policy_arn = aws_iam_policy.appsync_mutation_role_policy.arn
role = aws_iam_role.appsync_mutation_role.name
}
resource "aws_appsync_graphql_api" "graphql-api" {
name = "api"
authentication_type = "AWS_IAM"
schema = <<EOF
schema {
mutation: Mutation
query: Query
}
type Query {
testQuery: String
}
type Mutation {
testMutation(input: MutationInput!): TestMutationResult
}
type TestMutationResult {
test: String
}
input MutationInput {
testInput: String
}
EOF
}
```

## Argument Reference

-> **Note:** In order to be able to have your AWS Lambda function or
Expand Down Expand Up @@ -481,6 +576,7 @@ The following arguments are optional:
* `sagemaker_pipeline_target` - (Optional) Parameters used when you are using the rule to invoke an Amazon SageMaker Pipeline. Documented below. A maximum of 1 are allowed.
* `sqs_target` - (Optional) Parameters used when you are using the rule to invoke an Amazon SQS Queue. Documented below. A maximum of 1 are allowed.
* `target_id` - (Optional) The unique target assignment ID. If missing, will generate a random, unique id.
* `appsync_target` - (Optional) Parameters used when you are using the rule to invoke an AppSync GraphQL API mutation. Documented below. A maximum of 1 are allowed.

### batch_target

Expand Down Expand Up @@ -583,6 +679,10 @@ For more information, see [Task Networking](https://docs.aws.amazon.com/AmazonEC
* `name` - (Required) Name of parameter to start execution of a SageMaker Model Building Pipeline.
* `value` - (Required) Value of parameter to start execution of a SageMaker Model Building Pipeline.

### appsync_target

* `graphql_operation` - (Optional) Contains the GraphQL mutation to be parsed and executed.

## Attribute Reference

This resource exports no additional attributes.
Expand Down

0 comments on commit c93fffa

Please sign in to comment.