Skip to content

Commit

Permalink
Merges frank-bee:frank-bee-patch-1 (pull request #9)
Browse files Browse the repository at this point in the history
Merges frank-bee:frank-bee-patch-1 (pull request #9)
  • Loading branch information
frank-bee authored Apr 14, 2022
1 parent 57ce872 commit 6a96385
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,18 @@ No modules.
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC-ID | `string` | n/a | yes |
| <a name="input_create_new_ssm_document"></a> [create\_new\_ssm\_document](#input\_create\_new\_ssm\_document) | This module can create a new SSM document for the SSH Terminal | `bool` | `false` | no |
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | This module can create a security group for the bastion instance by default | `bool` | `true` | no |
| <a name="input_image_id"></a> [image\_id](#input\_image\_id) | AMI to be used. If blank, latest amazon linux 2 will be used | `string` | `""` | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | The instance type of the bastion | `string` | `"t3.nano"` | no |
| <a name="input_log_retention"></a> [log\_retention](#input\_log\_retention) | The amount of days the logs need to be kept | `number` | `30` | no |
| <a name="input_name"></a> [name](#input\_name) | The name to be interpolated, defaults to bastion-ssm-iam | `string` | `"bastion-ssm-iam"` | no |
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | The security group ids which can be given to the bastion instance, defaults to empty | `list(string)` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Tags to be added to the launch configuration for the bastion host, additionally to name tag | <pre>list(object({<br> key = string<br> value = string<br> propagate_at_launch = bool<br> }))</pre> | `[]` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_instance_profile_name"></a> [instance\_profile\_name](#output\_instance\_profile\_name) | The instance profile name of SSM |
| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | The security group id of the bastion server |
| <a name="output_ssm_document_name"></a> [ssm\_document\_name](#output\_ssm\_document\_name) | The document name of SSM |

Expand Down
2 changes: 1 addition & 1 deletion data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data "aws_ami" "amazon_linux_2" {
values = ["amazon"]
}

owners = ["amazon"] # Canonical
owners = ["amazon"]

filter {
name = "name"
Expand Down
17 changes: 11 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ data "template_file" "init" {

## Creating Launch Configuration
resource "aws_launch_configuration" "this" {
image_id = data.aws_ami.amazon_linux_2.id
image_id = var.image_id != "" ? var.image_id : data.aws_ami.amazon_linux_2.id
instance_type = var.instance_type
security_groups = concat(aws_security_group.allow_egress.*.id, var.security_group_ids)
associate_public_ip_address = false
Expand All @@ -84,9 +84,14 @@ resource "aws_autoscaling_group" "this" {
health_check_grace_period = 30
vpc_zone_identifier = var.subnet_ids

tag {
key = "Name"
value = var.name
propagate_at_launch = true
}
tags = concat(
[
{
key = "Name"
value = var.name
propagate_at_launch = true
},
],
var.tags,
)
}
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ output "ssm_document_name" {
description = "The document name of SSM"
value = local.ssm_document_name
}

output "instance_profile_name" {
description = "The instance profile name of SSM"
value = aws_iam_instance_profile.this.name
}
17 changes: 16 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ variable "instance_type" {
default = "t3.nano"
}

variable "image_id" {
type = string
description = "AMI to be used. If blank, latest amazon linux 2 will be used"
default = ""
}

variable "log_retention" {
type = number
description = "The amount of days the logs need to be kept"
Expand All @@ -32,7 +38,6 @@ variable "create_new_ssm_document" {
default = false
}


variable "create_security_group" {
type = bool
description = "This module can create a security group for the bastion instance by default"
Expand All @@ -44,3 +49,13 @@ variable "security_group_ids" {
description = "The security group ids which can be given to the bastion instance, defaults to empty"
default = []
}

variable "tags" {
type = list(object({
key = string
value = string
propagate_at_launch = bool
}))
description = "Tags to be added to the launch configuration for the bastion host, additionally to name tag"
default = []
}

0 comments on commit 6a96385

Please sign in to comment.