Skip to content

Commit f552f33

Browse files
authored
fix(module/asg): IAM Policy for Delicense Lambda (#12)
1 parent 2e9f6e3 commit f552f33

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

modules/asg/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ No modules.
6363
| <a name="input_bootstrap_options"></a> [bootstrap\_options](#input\_bootstrap\_options) | Bootstrap options to put into userdata | `any` | `{}` | no |
6464
| <a name="input_delete_timeout"></a> [delete\_timeout](#input\_delete\_timeout) | Timeout needed to correctly drain autoscaling group while deleting ASG.<br><br> By default in AWS timeout is set to 10 minutes, which is too low and causes issue:<br> Error: waiting for Auto Scaling Group (example-asg) drain: timeout while waiting for state to become '0' (last state: '1', timeout: 10m0s) | `string` | `"20m"` | no |
6565
| <a name="input_delicense_enabled"></a> [delicense\_enabled](#input\_delicense\_enabled) | If true, then Lambda is going to delicense FW before destroying VM-Series | `bool` | `false` | no |
66-
| <a name="input_delicense_ssm_param_name"></a> [delicense\_ssm\_param\_name](#input\_delicense\_ssm\_param\_name) | Secure string in Parameter Store with value in below format:<pre>{"username":"ACCOUNT","password":"PASSWORD","panorama1":"IP_ADDRESS1","panorama2":"IP_ADDRESS2","license_manager":"LICENSE_MANAGER_NAME"}"</pre> | `any` | `null` | no |
66+
| <a name="input_delicense_ssm_param_name"></a> [delicense\_ssm\_param\_name](#input\_delicense\_ssm\_param\_name) | Secure string in Parameter Store with value in below format:<pre>{"username":"ACCOUNT","password":"PASSWORD","panorama1":"IP_ADDRESS1","panorama2":"IP_ADDRESS2","license_manager":"LICENSE_MANAGER_NAME"}"</pre>the format can either be the plain name in case you store it without hierarchy or with a "/" in case you store in in a hierarchy | `any` | `null` | no |
6767
| <a name="input_desired_capacity"></a> [desired\_capacity](#input\_desired\_capacity) | Number of Amazon EC2 instances that should be running in the group. | `number` | `2` | no |
6868
| <a name="input_ebs_kms_id"></a> [ebs\_kms\_id](#input\_ebs\_kms\_id) | Alias for AWS KMS used for EBS encryption in VM-Series | `string` | `"alias/aws/ebs"` | no |
6969
| <a name="input_fw_license_type"></a> [fw\_license\_type](#input\_fw\_license\_type) | Select License type (byol/payg1/payg2) | `string` | `"byol"` | no |

modules/asg/main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ locals {
2828
default_eni_sg_ids = flatten([for k, v in var.interfaces : v.security_group_ids if v.device_index == 0])
2929
default_eni_public_ip = flatten([for k, v in var.interfaces : v.create_public_ip if v.device_index == 0])
3030
account_id = data.aws_caller_identity.current.account_id
31+
// this is done in case you store it in a hierarchy. if you just provide a name appennd a forward slash
32+
delicense_param = try(startswith(var.delicense_ssm_param_name, "/") ? var.delicense_ssm_param_name : "/${var.delicense_ssm_param_name}", null)
3133
autoscaling_config = {
3234
ip_target_groups = var.ip_target_groups
3335
}
@@ -257,7 +259,7 @@ resource "aws_iam_role_policy" "lambda_iam_policy_delicense" {
257259
"ssm:GetParameterHistory"
258260
],
259261
"Resource": [
260-
"arn:${data.aws_partition.this.partition}:ssm:${var.region}:${local.account_id}:parameter/${var.delicense_ssm_param_name}"
262+
"arn:${data.aws_partition.this.partition}:ssm:${var.region}:${local.account_id}:parameter${local.delicense_param}"
261263
]
262264
}
263265
]

modules/asg/variables.tf

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ variable "delicense_ssm_param_name" {
290290
```
291291
{"username":"ACCOUNT","password":"PASSWORD","panorama1":"IP_ADDRESS1","panorama2":"IP_ADDRESS2","license_manager":"LICENSE_MANAGER_NAME"}"
292292
```
293+
the format can either be the plain name in case you store it without hierarchy or with a "/" in case you store in in a hierarchy
293294
EOF
294295
default = null
295296
}

0 commit comments

Comments
 (0)