Home > Back-end >  What IAM policy or role is required for showing "aws-service" option on proxy method in Ap
What IAM policy or role is required for showing "aws-service" option on proxy method in Ap

Time:09-03

In API Gateway, Im having some issues getting "Aws Services" to show as an option in Integration Type when creating a method within a proxy resource. I can see that this is showing up for normal resource when I don't select the "proxy" checkbox, but if I check that box, and create a get method within the proxy resource, then I don't see that option.

enter image description here

CodePudding user response:

Proxy resources only support HTTP or Lambda integrations.

Here is how you can do this without using a proxy resource: enter image description here

Then for the policy and role:

resource "aws_iam_policy" "s3_policy" {
  name        = "s3-policy"
  description = "Policy for allowing all S3 Actions"

  policy = <<EOF
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::${local.bucket_name}-root/*"
        }
    ]
}
EOF
}


resource "aws_iam_role" "s3_api_gateyway_role" {
  name = "s3-api-gateyway-role"


  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "apigateway.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
  EOF
}

resource "aws_iam_role_policy_attachment" "s3_policy_attach" {
  role       = aws_iam_role.s3_api_gateyway_role.name
  policy_arn = aws_iam_policy.s3_policy.arn
}
  • Related