Skip to content

Commit

Permalink
Add support for installing third party software on EC2 (#63)
Browse files Browse the repository at this point in the history
* Add support for installing third party software on EC2

* Update the description of the variable nat_instance_user_data post_install

Co-authored-by: Ben Whaley <[email protected]>

* Update post install variable description in readme

Co-authored-by: Ben Whaley <[email protected]>

---------

Co-authored-by: Ben Whaley <[email protected]>
  • Loading branch information
eddycek and bwhaley authored Apr 27, 2023
1 parent f474668 commit 7cc5597
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ module "alternat_instances" {
}
```

The `nat_instance_user_data_post_install` variable allows you to run an additional script to be executed after the main configuration has been installed.

```hcl
module "alternat_instances" {
...
nat_instance_user_data_post_install = templatefile("${path.root}/post_install.tpl", {
VERSION_ENV = var.third_party_version
})
...
}
```

Feel free to submit a pull request or create an issue if you need an input or output that isn't available.

#### Can I use my own NAT Gateways?
Expand Down
9 changes: 9 additions & 0 deletions modules/terraform-aws-alternat/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ data "cloudinit_config" "config" {
content_type = "text/x-shellscript"
content = file("${path.module}/../../scripts/alternat.sh")
}

dynamic "part" {
for_each = var.nat_instance_user_data_post_install != "" ? [1] : []

content {
content_type = "text/x-shellscript"
content = var.nat_instance_user_data_post_install
}
}
}

resource "aws_launch_template" "nat_instance_template" {
Expand Down
6 changes: 6 additions & 0 deletions modules/terraform-aws-alternat/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ variable "nat_instance_eip_ids" {
default = []
}

variable "nat_instance_user_data_post_install" {
description = "Post-install shell script to run at boot after configuring alternat."
type = string
default = ""
}

variable "tags" {
description = "A map of tags to add to all supported resources managed by the module."
type = map(string)
Expand Down

0 comments on commit 7cc5597

Please sign in to comment.