Skip to content

Commit 1f5acc4

Browse files
committed
feat: add SSM write permissions
1 parent 09b372c commit 1f5acc4

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

Diff for: README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,26 @@ Here is an example of using this module:
7171

7272
## Providers
7373

74-
| Name | Version |
75-
| ------------------------------------------------------------------ | --------- |
76-
| <a name="provider_tailscale"></a> [tailscale](#provider_tailscale) | >= 0.13.7 |
74+
| Name | Version |
75+
| ------------------------------------------------------------------ | ------- |
76+
| <a name="provider_aws"></a> [aws](#provider_aws) | 5.76.0 |
77+
| <a name="provider_tailscale"></a> [tailscale](#provider_tailscale) | 0.17.2 |
7778

7879
## Modules
7980

8081
| Name | Source | Version |
8182
| -------------------------------------------------------------------------------------------------------- | ---------------------------------- | ------- |
83+
| <a name="module_ssm_policy"></a> [ssm_policy](#module_ssm_policy) | cloudposse/iam-policy/aws | 2.0.1 |
8284
| <a name="module_ssm_state"></a> [ssm_state](#module_ssm_state) | cloudposse/ssm-parameter-store/aws | 0.13.0 |
8385
| <a name="module_tailscale_subnet_router"></a> [tailscale_subnet_router](#module_tailscale_subnet_router) | masterpointio/ssm-agent/aws | 1.2.0 |
8486
| <a name="module_this"></a> [this](#module_this) | cloudposse/label/null | 0.25.0 |
8587

8688
## Resources
8789

88-
| Name | Type |
89-
| ------------------------------------------------------------------------------------------------------------------------------ | -------- |
90-
| [tailscale_tailnet_key.default](https://registry.terraform.io/providers/tailscale/tailscale/latest/docs/resources/tailnet_key) | resource |
90+
| Name | Type |
91+
| ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
92+
| [aws_iam_role_policy_attachment.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
93+
| [tailscale_tailnet_key.default](https://registry.terraform.io/providers/tailscale/tailscale/latest/docs/resources/tailnet_key) | resource |
9194

9295
## Inputs
9396

Diff for: main.tf

+31
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ locals {
1414

1515
tailscale_up_extra_flags_enabled = length(var.tailscale_up_extra_flags) > 0
1616

17+
additional_policies = length(try(module.ssm_policy[0].arn, [])) > 0 ? [module.ssm_policy[0].arn] : []
18+
1719
userdata = templatefile("${path.module}/userdata.sh.tmpl", {
1820
authkey = tailscale_tailnet_key.default.key
1921
exit_node_enabled = var.exit_node_enabled
@@ -90,3 +92,32 @@ module "ssm_state" {
9092
context = module.this.context
9193
tags = module.this.tags
9294
}
95+
96+
module "ssm_policy" {
97+
count = var.ssm_state_enabled ? 1 : 0
98+
source = "cloudposse/iam-policy/aws"
99+
version = "2.0.1"
100+
101+
name = "ssm"
102+
description = "Additional SSM access for SSM Agent"
103+
iam_policy = [{
104+
statements = [
105+
{
106+
sid = "SSMAgentPutParameter"
107+
effect = "Allow"
108+
actions = ["ssm:PutParameter"]
109+
resources = [
110+
module.ssm_state[0].arn_map[local.ssm_state_param_name],
111+
]
112+
},
113+
]
114+
}]
115+
context = module.this.context
116+
tags = module.this.tags
117+
}
118+
119+
resource "aws_iam_role_policy_attachment" "default" {
120+
for_each = toset(local.additional_policies)
121+
role = module.tailscale_subnet_router.role_id
122+
policy_arn = each.value
123+
}

0 commit comments

Comments
 (0)