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

Parse policy JSON #16

Open
tlvince opened this issue Sep 12, 2018 · 0 comments
Open

Parse policy JSON #16

tlvince opened this issue Sep 12, 2018 · 0 comments

Comments

@tlvince
Copy link

tlvince commented Sep 12, 2018

For the following plan:

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  ~ module.iam_role_for_event_filter_lambda.aws_iam_policy.iam_policy
      policy:                "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"logs:CreateLogGroup\",\n        \"logs:CreateLogStream\",\n        \"logs:PutLogEvents\"\n      ],\n      \"Resource\": [\"*\"]\n  }\n  ]\n}\n" => "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"logs:CreateLogGroup\",\n        \"logs:CreateLogStream\",\n        \"logs:PutLogEvents\"\n      ],\n      \"Resource\": [\"*\"]\n    },\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\"kinesis:GetRecords\"],\n      \"Resource\": [\"arn:aws:kinesis:eu-west-2:xxx:stream/xxx\"]\n    }\n  ]\n}\n"


Plan: 0 to add, 1 to change, 0 to destroy.

... terraform-plan-parser currently outputs (abbreviated):

    {
      "action": "update",
      "type": "aws_iam_policy",
      "name": "iam_policy",
      "path": "module.iam_role_for_event_filter_lambda.aws_iam_policy.iam_policy",
      "changedAttributes": {
        "policy": {
          "old": {
            "type": "string",
            "value": "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"logs:CreateLogGroup\",\n        \"logs:CreateLogStream\",\n        \"logs:PutLogEvents\"\n      ],\n      \"Resource\": [\"*\"]\n  }\n  ]\n}\n"
          },
          "new": {
            "type": "string",
            "value": "{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"logs:CreateLogGroup\",\n        \"logs:CreateLogStream\",\n        \"logs:PutLogEvents\"\n      ],\n      \"Resource\": [\"*\"]\n    },\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": [\"kinesis:GetRecords\"],\n      \"Resource\": [\"arn:aws:kinesis:eu-west-2:xxx:stream/xxx\"]\n    }\n  ]\n}\n"
          }
        }
      },
      "module": "iam_role_for_event_filter_lambda"
    }

It' d be nice if the policy JSON could also be parsed, e.g. for old.value:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

Probably this can be generalised for other types of JSON values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant