-
-
Notifications
You must be signed in to change notification settings - Fork 223
Add ssm patch support #104
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
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
294928e
Adding SSM patch support
jamengual 053ceae
Auto Format
cloudpossebot 6133cbf
remove uneeded change
jamengual 7eac546
Merge branch 'add_ssm_patch_support' of github.com:cloudposse/terrafo…
jamengual ad03b75
remove uneeded change
jamengual 2b17d4e
Auto Format
cloudpossebot 9219b10
Update main.tf
jamengual 193d691
Update main.tf
jamengual 07de895
Update variables.tf
jamengual 9f1088c
Auto Format
cloudpossebot 9f00bf2
Update main.tf
jamengual 1a98cd1
Update main.tf
jamengual 1edc0a8
Adding SSM patch support
jamengual b798e3a
Update main.tf
jamengual 336799f
Auto Format
cloudpossebot 7894217
Fixinf var name
jamengual 271fe61
Fixinf var name
jamengual 16ab864
Merge branch 'add_ssm_patch_support' of github.com:cloudposse/terrafo…
jamengual d4901ac
Fixing variable name for count
jamengual d52b935
Fixing variable name for count and adding label module + attribute
jamengual f60e8af
Auto Format
cloudpossebot c50f64b
Update main.tf
jamengual 0ed01c4
Update main.tf
jamengual ebe00ab
Minor fixes
jamengual 5b0e320
Fixing broken resource reference
jamengual 143adf9
Fixing broken resource reference
jamengual c6007a7
Adding ssm_enabled variable
jamengual bf5a548
Auto Format
cloudpossebot 9a1f4d5
removing ssm locals
jamengual 4249afd
Merge branch 'add_ssm_patch_support' of github.com:cloudposse/terrafo…
jamengual d7bb430
Fixing count logic
jamengual e33737d
Auto Format
cloudpossebot ee6f944
Fixing count logic
jamengual b56b7b7
Fixing count logic
jamengual 9a6d909
Fixing count logic
jamengual caad396
Fixing count logic
jamengual e6d3961
Fixing count logic
jamengual 65f5dde
Update ssm_patch.tf
jamengual 957753b
Update main.tf
jamengual a2d0b29
Update variables.tf
jamengual 2799d5a
Update variables.tf
jamengual c9722d4
Auto Format
cloudpossebot 2971069
more feedback fixes
jamengual 660fba9
Merge branch 'add_ssm_patch_support' of github.com:cloudposse/terrafo…
jamengual b36d99e
more doc fixes
jamengual 59dfce4
Removing duplicated resources
jamengual f146d74
Update ssm_patch.tf
jamengual f41d16a
Auto Format
cloudpossebot a740fa2
Addressing Feedback
jamengual dea8bb4
Merge branch 'add_ssm_patch_support' of github.com:cloudposse/terrafo…
jamengual 10f2467
Auto Format
cloudpossebot 99c9d8f
fixing local name
jamengual 19fa1cf
reverting logic from master
jamengual File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
locals { | ||
ssm_patch_log_bucket_enabled = local.ssm_enabled && var.ssm_patch_manager_s3_log_bucket != "" && var.ssm_patch_manager_s3_log_bucket != null | ||
ssm_policy_arn = var.ssm_patch_manager_iam_policy_arn == null || var.ssm_patch_manager_iam_policy_arn == "" ? "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore" : var.ssm_patch_manager_iam_policy_arn | ||
ssm_enabled = local.enabled && var.ssm_patch_manager_enabled | ||
} | ||
|
||
module "label_ssm_patch_s3_log_policy" { | ||
source = "cloudposse/label/null" | ||
version = "0.24.1" | ||
|
||
enabled = local.ssm_patch_log_bucket_enabled | ||
attributes = ["ssm-patch-s3-logs"] | ||
aknysh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
context = module.this.context | ||
} | ||
|
||
data "aws_iam_policy_document" "ssm_patch_s3_log_policy" { | ||
count = local.ssm_patch_log_bucket_enabled ? 1 : 0 | ||
statement { | ||
sid = "AllowAccessToPathLogBucket" | ||
actions = [ | ||
"s3:GetObject", | ||
"s3:PutObject", | ||
"s3:PutObjectAcl", | ||
"s3:GetEncryptionConfiguration", | ||
] | ||
resources = [ | ||
"arn:aws:s3:::${var.ssm_patch_manager_s3_log_bucket}/*", | ||
"arn:aws:s3:::${var.ssm_patch_manager_s3_log_bucket}", | ||
] | ||
} | ||
} | ||
|
||
resource "aws_iam_policy" "ssm_patch_s3_log_policy" { | ||
count = local.ssm_patch_log_bucket_enabled ? 1 : 0 | ||
name = module.label_ssm_patch_s3_log_policy.id | ||
path = "/" | ||
description = "Policy to allow the local SSM agent on the instance to write the log output to the defined bucket" | ||
policy = data.aws_iam_policy_document.ssm_patch_s3_log_policy[0].json | ||
} | ||
|
||
|
||
resource "aws_iam_role_policy_attachment" "ssm_core" { | ||
count = local.ssm_enabled ? local.instance_profile_count : 0 | ||
role = aws_iam_role.default[count.index].name | ||
policy_arn = local.ssm_policy_arn | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "ssm_s3_policy" { | ||
count = local.ssm_patch_log_bucket_enabled ? local.instance_profile_count : 0 | ||
role = aws_iam_role.default[count.index].name | ||
policy_arn = aws_iam_policy.ssm_patch_s3_log_policy[0].arn | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.