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

Warn user if AWS IAM policy starts not with opening brace #14652

Closed
VladRassokhin opened this issue May 19, 2017 · 1 comment · Fixed by #14669
Closed

Warn user if AWS IAM policy starts not with opening brace #14652

VladRassokhin opened this issue May 19, 2017 · 1 comment · Fixed by #14669

Comments

@VladRassokhin
Copy link
Contributor

Terraform Version

0.9.5

Affected Resource(s)

  • aws_iam_role_policy
    And probably all other resources related to IAM policies

Terraform Configuration Files

resource "aws_iam_role_policy" "ec2_monitoring_lambda_basic_execution" {
  depends_on = [
    "aws_lambda_function.enable_ec2_monitoring"]
  role = "${aws_iam_role.enable_ec2_monitoring.id}"
  policy = <<EOF
  {
      "Version": "2012-10-17",
      "Statement": [
          {
              "Effect": "Allow",
              "Action": ["logs:CreateLogGroup"],
              "Resource": ["arn:aws:logs:${var.aws_region}:${data.aws_caller_identity.current.account_id}:*"]
          }
      ]
  }
  EOF
}

Note that << heredoc used, <<- fixes problem as leading indentation removed.

Actual Behavior

Error putting IAM role policy terraform-00548fa690bb6d77afd48870ec: MalformedPolicyDocument: The policy failed legacy parsing
        status code: 400,

Caused by leading spaces before opening brace ({) in policy definition

Expected Behavior

Validation should fail for such policies or Terraform should silently remove leading spaces
As validation, Terraform could do simple json validation of policies.

Steps to Reproduce

  1. terraform apply
@ghost
Copy link

ghost commented Apr 12, 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 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.

@ghost ghost unassigned grubernaut Apr 12, 2020
@ghost ghost locked and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants