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

fix: add quotes around subnet ids #6

Merged
merged 7 commits into from
May 16, 2022
Merged

Conversation

mohdnr
Copy link
Contributor

@mohdnr mohdnr commented May 16, 2022

Subnet ids are no longer encapsulated by quotes since the refactor due to receiving this value from a list(string) which is dropping the quotes.

Also tweaked the TF workflow so that the lambda dist folder is always available due to archive files ignoring depends_on

Note: some extra changes to SSM since i updated the account list so i can run one end to end run using only my scratch account as a target

@mohdnr mohdnr requested a review from patheard May 16, 2022 19:10
@github-actions
Copy link

cloud_asset_inventory

✅   Terraform Format: success
✅   Terraform Plan: success
✅   Conftest: success

Plan: 0 to add, 5 to change, 0 to destroy
Show plan
Resource actions are indicated with the following symbols:
  ~ update in-place
 <= read (data resources)

Terraform will perform the following actions:

  # data.aws_iam_policy_document.asset_inventory_cartography_state_machine will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "asset_inventory_cartography_state_machine"  {
      ~ id      = "739580681" -> (known after apply)
      ~ json    = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = [
                          - "iam:PassRole",
                          - "iam:GetRole",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:iam::794722365809:role/secopsAssetInventoryCartographyRole",
                          - "arn:aws:iam::794722365809:role/cartography_container_execution_role",
                        ]
                      - Sid      = ""
                    },
                  - {
                      - Action   = "states:StartExecution"
                      - Effect   = "Allow"
                      - Resource = "arn:aws:states:ca-central-1:794722365809:stateMachine:asset-inventory-cartography"
                      - Sid      = ""
                    },
                  - {
                      - Action   = "ecs:ListTasks"
                      - Effect   = "Allow"
                      - Resource = "*"
                      - Sid      = ""
                    },
                  - {
                      - Action   = "ecs:RunTask"
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:ecs:ca-central-1:794722365809:task-definition/cartography:4",
                          - "arn:aws:ecs:ca-central-1:794722365809:task-definition/cartography",
                        ]
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "events:PutTargets",
                          - "events:PutRule",
                          - "events:DescribeRule",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:events:ca-central-1:794722365809:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule"
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "ssm:GetParameter",
                          - "ssm:DescribeParameters",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/asset_inventory_account_list"
                      - Sid      = ""
                    },
                  - {
                      - Action   = "lambda:InvokeFunction"
                      - Effect   = "Allow"
                      - Resource = "arn:aws:lambda:ca-central-1:794722365809:function:sentinel-neo4j-forwarder"
                      - Sid      = ""
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> (known after apply)
      - version = "2012-10-17" -> null

      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
    }

  # data.aws_iam_policy_document.cartography_policies will be read during apply
  # (config refers to values not yet known)
 <= data "aws_iam_policy_document" "cartography_policies"  {
      ~ id      = "646190638" -> (known after apply)
      ~ json    = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = "sts:AssumeRole"
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:iam::996667111599:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::957818836222:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::955148791056:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::925306372402:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::902343555465:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::894242006032:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::871282759583:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::843973686572:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::820252213580:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::806545929748:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::805525519938:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::794722365809:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::773858180673:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::762579868088:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::729164266357:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::722713121070:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::687401027353:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::637287734259:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::595701125956:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::563894450011:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::537819865265:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::515018049985:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::507252742351:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::473697194269:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::472286471787:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::414662622316:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::406214159830:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::400061975867:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::349837941862:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::339850311124:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::296255494825:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::283582579564:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::276192857112:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::239043911459:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::236007890657:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::160411545784:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::136676205420:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::124044056575:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::059208818674:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::028051698106:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::009883649233:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::005133826942:role/secopsAssetInventorySecurityAuditRole",
                        ]
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "ecr:GetDownloadUrlForLayer",
                          - "ecr:GetAuthorizationToken",
                          - "ecr:BatchGetImage",
                          - "ecr:BatchCheckLayerAvailability",
                        ]
                      - Effect   = "Allow"
                      - Resource = "*"
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "ssm:GetParameters",
                          - "ssm:DescribeParameters",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/neo4j_password",
                          - "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/neo4j_auth",
                          - "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/asset_inventory_account_list",
                        ]
                      - Sid      = ""
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> (known after apply)
      - version = "2012-10-17" -> null

      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
      ~ statement {
          - not_actions   = [] -> null
          - not_resources = [] -> null
            # (3 unchanged attributes hidden)
        }
    }

  # aws_iam_policy.asset_inventory_cartography_state_machine will be updated in-place
  ~ resource "aws_iam_policy" "asset_inventory_cartography_state_machine" {
        id        = "arn:aws:iam::794722365809:policy/CartographyStateMachineECSLambda"
        name      = "CartographyStateMachineECSLambda"
      ~ policy    = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = [
                          - "iam:PassRole",
                          - "iam:GetRole",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:iam::794722365809:role/secopsAssetInventoryCartographyRole",
                          - "arn:aws:iam::794722365809:role/cartography_container_execution_role",
                        ]
                      - Sid      = ""
                    },
                  - {
                      - Action   = "states:StartExecution"
                      - Effect   = "Allow"
                      - Resource = "arn:aws:states:ca-central-1:794722365809:stateMachine:asset-inventory-cartography"
                      - Sid      = ""
                    },
                  - {
                      - Action   = "ecs:ListTasks"
                      - Effect   = "Allow"
                      - Resource = "*"
                      - Sid      = ""
                    },
                  - {
                      - Action   = "ecs:RunTask"
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:ecs:ca-central-1:794722365809:task-definition/cartography:4",
                          - "arn:aws:ecs:ca-central-1:794722365809:task-definition/cartography",
                        ]
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "events:PutTargets",
                          - "events:PutRule",
                          - "events:DescribeRule",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:events:ca-central-1:794722365809:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule"
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "ssm:GetParameter",
                          - "ssm:DescribeParameters",
                        ]
                      - Effect   = "Allow"
                      - Resource = "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/asset_inventory_account_list"
                      - Sid      = ""
                    },
                  - {
                      - Action   = "lambda:InvokeFunction"
                      - Effect   = "Allow"
                      - Resource = "arn:aws:lambda:ca-central-1:794722365809:function:sentinel-neo4j-forwarder"
                      - Sid      = ""
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> (known after apply)
        tags      = {
            "CostCentre" = "security-tools-794722365809"
            "Product"    = "security-tools-cloud-asset-inventory"
            "Terraform"  = "true"
        }
        # (4 unchanged attributes hidden)
    }

  # aws_iam_policy.cartography_policies will be updated in-place
  ~ resource "aws_iam_policy" "cartography_policies" {
        id        = "arn:aws:iam::794722365809:policy/CartographyContainerExecutionPolicies"
        name      = "CartographyContainerExecutionPolicies"
      ~ policy    = jsonencode(
            {
              - Statement = [
                  - {
                      - Action   = "sts:AssumeRole"
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:iam::996667111599:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::957818836222:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::955148791056:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::925306372402:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::902343555465:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::894242006032:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::871282759583:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::843973686572:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::820252213580:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::806545929748:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::805525519938:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::794722365809:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::773858180673:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::762579868088:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::729164266357:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::722713121070:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::687401027353:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::637287734259:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::595701125956:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::563894450011:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::537819865265:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::515018049985:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::507252742351:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::473697194269:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::472286471787:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::414662622316:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::406214159830:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::400061975867:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::349837941862:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::339850311124:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::296255494825:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::283582579564:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::276192857112:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::239043911459:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::236007890657:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::160411545784:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::136676205420:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::124044056575:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::059208818674:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::028051698106:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::009883649233:role/secopsAssetInventorySecurityAuditRole",
                          - "arn:aws:iam::005133826942:role/secopsAssetInventorySecurityAuditRole",
                        ]
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "ecr:GetDownloadUrlForLayer",
                          - "ecr:GetAuthorizationToken",
                          - "ecr:BatchGetImage",
                          - "ecr:BatchCheckLayerAvailability",
                        ]
                      - Effect   = "Allow"
                      - Resource = "*"
                      - Sid      = ""
                    },
                  - {
                      - Action   = [
                          - "ssm:GetParameters",
                          - "ssm:DescribeParameters",
                        ]
                      - Effect   = "Allow"
                      - Resource = [
                          - "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/neo4j_password",
                          - "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/neo4j_auth",
                          - "arn:aws:ssm:ca-central-1:794722365809:parameter/cartography/asset_inventory_account_list",
                        ]
                      - Sid      = ""
                    },
                ]
              - Version   = "2012-10-17"
            }
        ) -> (known after apply)
        tags      = {
            "CostCentre" = "security-tools-794722365809"
            "Product"    = "security-tools-cloud-asset-inventory"
            "Terraform"  = "true"
        }
        # (4 unchanged attributes hidden)
    }

  # aws_lambda_function.neo4j_to_sentinel will be updated in-place
  ~ resource "aws_lambda_function" "neo4j_to_sentinel" {
        id                             = "sentinel-neo4j-forwarder"
      ~ last_modified                  = "2022-05-16T19:00:20.518+0000" -> (known after apply)
      ~ source_code_hash               = "IY7bPAsx1pUUaP9SGN85oqAyz2sPscV2luBTgcsi0DI=" -> "q/2/3LCfS2Ld1vHNWdbmIOVVA+sD68EunSB7TaMwYZY="
        tags                           = {
            "CostCentre" = "security-tools-794722365809"
            "Product"    = "security-tools"
            "Terraform"  = "true"
        }
        # (24 unchanged attributes hidden)



        # (3 unchanged blocks hidden)
    }

  # aws_sfn_state_machine.asset_inventory_cartography will be updated in-place
  ~ resource "aws_sfn_state_machine" "asset_inventory_cartography" {
      ~ definition    = jsonencode(
          ~ {
              ~ States         = {
                  ~ Map                = {
                      ~ Iterator       = {
                          ~ States  = {
                              ~ Cartography = {
                                  ~ Parameters = {
                                      ~ NetworkConfiguration     = {
                                          ~ AwsvpcConfiguration = {
                                              ~ Subnets        = [
                                                  - "subnet-08cab5daf34489c53, subnet-07f8e17bbf11b0797, subnet-0d92713028fd15243",
                                                  + "subnet-08cab5daf34489c53",
                                                  + "subnet-07f8e17bbf11b0797",
                                                  + "subnet-0d92713028fd15243",
                                                ]
                                                # (1 unchanged element hidden)
                                            }
                                        }
                                        # (4 unchanged elements hidden)
                                    }
                                    # (4 unchanged elements hidden)
                                }
                                # (1 unchanged element hidden)
                            }
                            # (1 unchanged element hidden)
                        }
                        # (5 unchanged elements hidden)
                    }
                    # (1 unchanged element hidden)
                }
                # (3 unchanged elements hidden)
            }
        )
        id            = "arn:aws:states:ca-central-1:794722365809:stateMachine:asset-inventory-cartography"
        name          = "asset-inventory-cartography"
        tags          = {
            "CostCentre" = "security-tools-794722365809"
            "Product"    = "security-tools-cloud-asset-inventory"
            "Terraform"  = "true"
        }
        # (6 unchanged attributes hidden)


        # (2 unchanged blocks hidden)
    }

  # aws_ssm_parameter.asset_inventory_account_list will be updated in-place
  ~ resource "aws_ssm_parameter" "asset_inventory_account_list" {
        id        = "/cartography/asset_inventory_account_list"
        name      = "/cartography/asset_inventory_account_list"
        tags      = {
            "CostCentre" = "security-tools-794722365809"
            "Product"    = "security-tools-cloud-asset-inventory"
            "Terraform"  = "true"
        }
      ~ value     = (sensitive value)
      ~ version   = 2 -> (known after apply)
        # (5 unchanged attributes hidden)
    }

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

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: plan.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "plan.tfplan"
Releasing state lock. This may take a few moments...
Show Conftest results
18 tests, 18 passed, 0 warnings, 0 failures, 0 exceptions

@mohdnr mohdnr merged commit 78965f6 into main May 16, 2022
@mohdnr mohdnr deleted the fix/add_quotes_to_subnet_ids branch May 16, 2022 20:15
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

Successfully merging this pull request may close these issues.

2 participants