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

Move Lambda Vars to Parameter Store #941

Merged
merged 36 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
736a854
fix(scale): Refactor Runner Type and Owner (#871)
mcaulifn Jun 15, 2021
6e35845
feat: support multiple instance types (#898)
mcaulifn Jun 16, 2021
a768687
docs: fix lambda_security_group_ids incorrect description #738 (#902)
npalm Jun 17, 2021
5b5ee3b
fix: scale down runners (#905)
npalm Jun 17, 2021
8746249
chore: group upgrade lambda dependencies (#906)
npalm Jun 17, 2021
7bda880
feat(runner): Move Lambda Vars to Parameter Store
mcaulifn Jun 23, 2021
333eae7
Add test for ssm module (#1)
mcaulifn Jun 25, 2021
65535fb
Removing KMS/GH Auth from scale-down
mcaulifn Jun 25, 2021
b460a1a
Merge branch 'mcaulifn/ssm' of https://github.com/mcaulifn/terraform-…
mcaulifn Jun 25, 2021
aecc383
Add SSM permissions to runner policy
mcaulifn Jun 30, 2021
c84ae6c
Allow custom key_id
mcaulifn Jun 30, 2021
d2b61f1
Fixing for loop
mcaulifn Jun 30, 2021
8f34d71
Move SSM policy to Lambdas
mcaulifn Jul 1, 2021
7d44ac8
Fixing function call
mcaulifn Jul 1, 2021
66bd078
chore: Bump aws-sdk (#752) (#909)
dependabot[bot] Jun 18, 2021
77c8e13
chore: Bump aws-sdk (#752) (#908)
dependabot[bot] Jun 18, 2021
fe0a126
chore: Bump aws-sdk (#752) (#887)
dependabot[bot] Jun 18, 2021
174b4ca
chore: Bump aws-sdk (#752) (#885)
dependabot[bot] Jun 18, 2021
0f1493f
chore: Bump aws-sdk (#752) (#889)
dependabot[bot] Jun 18, 2021
5314469
chore: Bump aws-sdk (#752) (#892)
dependabot[bot] Jun 18, 2021
640ef5f
chore: Bump aws-sdk (#752) (#907)
dependabot[bot] Jun 18, 2021
1658635
chore: Bump aws-sdk (#752) (#864)
dependabot[bot] Jun 18, 2021
a401c0d
chore: Bump eslint in /modules/webhook/lambdas/webhook (#918)
dependabot[bot] Jun 24, 2021
870280b
chore: Bump typescript (#929)
dependabot[bot] Jun 24, 2021
0fdf8cf
chore: Bump @typescript-eslint/eslint-plugin (#928)
dependabot[bot] Jun 24, 2021
a6b9a29
chore: Bump typescript in /modules/webhook/lambdas/webhook (#926)
dependabot[bot] Jun 24, 2021
b5096bb
feat: Added support for white listing of repositories (#915)
ravenolf Jul 7, 2021
7ac1a25
Need `,` after list item
mcaulifn Jul 7, 2021
cbf7a70
Move Lambda Policy to data resource
mcaulifn Jul 7, 2021
d8e6fbd
Merge branch 'develop' into mcaulifn/ssm
mcaulifn Jul 7, 2021
d46f9e2
Merge branch 'develop' into mcaulifn/ssm
mcaulifn Jul 14, 2021
0c9aff5
Addressing PR comments, fixing lint
mcaulifn Jul 16, 2021
3104d34
Refactoring Parameters to SSM Module
mcaulifn Jul 27, 2021
7c09270
Merge branch 'develop' into mcaulifn/ssm
mcaulifn Jul 27, 2021
4ea2a17
Fixing rebase
mcaulifn Jul 27, 2021
19199e3
Using only key ARN as input value
mcaulifn Jul 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions modules/runners/policies-runner.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ resource "aws_iam_role_policy" "ssm_parameters" {
role = aws_iam_role.runner.name
policy = templatefile("${path.module}/policies/instance-ssm-parameters-policy.json",
{
arn_ssm_parameters = "arn:aws:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter/${var.environment}-*"
arns = [
"arn:aws:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter/${var.environment}-*",
"arn:aws:ssm:${var.aws_region}:${data.aws_caller_identity.current.account_id}:parameter/${var.environment}/*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a second thougt, this change grants the runner instance role to read any parameter in SSM. The runner should only able to read the token generated for the instance. So suggest we only grant the runner access to environment-*. I will refactor this later in even a more clear path that only gives access to this token. We should avoid that a process in the runner could call the aws api and fetch the token to start acting as the app.

With updating this policy you change only the policies attached to runner. I think it is better to create a new template, for example lambda-ssm-parameter-policies.json. Which you grant read access to the pramaters in the path environment/github_app/* So it clear that the lambda can act on behalf of the app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I'll draft up something a bit more limiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is already a lambda policy template that has SSM permissions.

]
}
)
}
Expand All @@ -46,4 +49,4 @@ resource "aws_iam_role_policy_attachment" "managed_policies" {
policy_arn = element(var.runner_iam_role_managed_policy_arns, count.index)
}

// see also logging.tf for logging and metrics policies
// see also logging.tf for logging and metrics policies
16 changes: 13 additions & 3 deletions modules/runners/policies/instance-ssm-parameters-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
"Statement": [
{
"Effect": "Allow",
"Action": ["ssm:DeleteParameter"],
"Resource": "${arn_ssm_parameters}"
"Action": [
"ssm:DeleteParameter"
],
"Resource": [
%{~ for arn in arns ~}
"${arn_ssm_parameters}"
%{~ endfor ~}
]
},
{
"Effect": "Allow",
"Action": [
"ssm:GetParameters",
"ssm:GetParameter"
],
"Resource": "${arn_ssm_parameters}"
"Resource": [
%{~ for arn in arns ~}
"${arn_ssm_parameters}"
%{~ endfor ~}
]
}
]
}