Skip to content

JamesWoolfenden/terraform-aws-appsync

Repository files navigation

terraform-aws-appsync

Build Status Latest Release GitHub tag (latest SemVer) Terraform Version Infrastructure Tests pre-commit checkov Infrastructure Tests

Terraform module -


It's 100% Open Source and licensed under the APACHE2.

Usage

This is just a very basic example.

alt text

Include module.appsync.tf this repository as a module in your existing terraform code:

module "appsync" {
  source      = "JamesWoolfenden/appsync/aws"
  version     = "0.0.4"
  common_tags          = var.common_tags
  lambda_resolver_arn  = var.lambda_resolver_arn
  datasource_user_name = var.datasource_user_name
  api_name             = var.api_name
  request_template     = file("${path.module}/templates/request")
  response_template    = file("${path.module}/templates/response")
  schema               = file("${path.module}/templates/schema")
  resolver_field       = "singlePost"
  resolver_type        = "Query"
  kms_key_id           = aws_kms_key.example.arn
  web_acl_arn          = module.waf2.aws_wafv2_web_acl.arn
}

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_appsync_datasource.user resource
aws_appsync_graphql_api.main resource
aws_appsync_resolver.user resource
aws_cloudwatch_log_group.api resource
aws_iam_role.appsync resource
aws_iam_role_policy_attachment.attach resource
aws_wafv2_web_acl_association.example resource

Inputs

Name Description Type Default Required
api_name n/a string "hitme" no
appsync_rolename The name of the role to attach to appsync string "Appsync" no
common_tags This is a map type for applying tags on resources map(any) n/a yes
datasource_user_name n/a string "hitme_user" no
kms_key_id KMS key arn string n/a yes
lambda_resolver_arn n/a string n/a yes
log_level log level for the api string "ERROR" no
request_template n/a string n/a yes
resolver_field (optional) describe your variable string n/a yes
resolver_type (optional) describe your variable string n/a yes
response_template n/a string n/a yes
retention_in_days How long Cloudwatch retains your logs number 90 no
schema n/a string n/a yes
web_acl_arn n/a string n/a yes

Outputs

Name Description
api n/a
datasource n/a
resolver n/a

Policy

The Terraform resource required is:

resource "aws_iam_policy" "terraform_pike" {
  name_prefix = "terraform_pike"
  path        = "/"
  description = "Pike Autogenerated policy from IAC"

  policy = jsonencode({
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "iam:AttachRolePolicy",
                "iam:CreateRole",
                "iam:DeleteRole",
                "iam:DetachRolePolicy",
                "iam:GetRole",
                "iam:ListAttachedRolePolicies",
                "iam:ListInstanceProfilesForRole",
                "iam:ListRolePolicies",
                "iam:TagRole"
            ],
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "logs:AssociateKmsKey",
                "logs:CreateLogGroup",
                "logs:DeleteLogGroup",
                "logs:DeleteRetentionPolicy",
                "logs:DescribeLogGroups",
                "logs:DisassociateKmsKey",
                "logs:ListTagsLogGroup",
                "logs:PutRetentionPolicy"
            ],
            "Resource": "*"
        }
    ]
})
}

Related Projects

Check out these related projects.

Help

Got a question?

File a GitHub issue.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Copyrights

Copyright � 2019-2022 James Woolfenden

License

License

See LICENSE for full details.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors

James Woolfenden
James Woolfenden