-
-
Notifications
You must be signed in to change notification settings - Fork 223
Add possibility to use custom User Data
#20
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
Conversation
has been tested with following manifest data "aws_ami" "pfsense" {
most_recent = "true"
filter {
name = "description"
values = ["Netgate pfSense Certified 2.3.4"]
}
}
data "template_file" "init" {
template = "${file("1.sh")}"
}
module "admin_tier" {
source = "cloudposse/terraform-aws-ec2-instance"
ssh_key_pair = "sweetops"
ami = "${data.aws_ami.pfsense.image_id}"
vpc_id = "vpc-someid"
subnet = "subnet-someid"
associate_public_ip_address = "true"
create_default_security_group = "false"
name = "pf"
namespace = "cp"
stage = "dev"
user_data = ["${data.template_file.init.rendered}"]
}
module "admin_tier1" {
source = "cloudposse/terraform-aws-ec2-instance"
ssh_key_pair = "sweetops"
ami = "${data.aws_ami.pfsense.image_id}"
vpc_id = "vpc-someid"
subnet = "subnet-someid"
associate_public_ip_address = "true"
create_default_security_group = "false"
name = "pf1"
namespace = "cp"
stage = "dev"
custom_user_data = ["${data.template_file.init.rendered}"]
}
|
README.md
Outdated
@@ -56,7 +56,7 @@ module "kafka_instance" { | |||
This module depends on these modules: | |||
|
|||
* [terraform-null-label](https://github.com/cloudposse/terraform-null-label) | |||
* [terraform-template-user-data-github-authorized-keys](https://github.com/cloudposse/terraform-template-user-data-github-authorized-keys) | |||
* [terraform-template-User Data-github-authorized-keys](https://github.com/cloudposse/terraform-template-user-data-github-authorized-keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to terraform-template-user-data-github-authorized-keys
.
README.md
Outdated
| `statistic_level` | `Maximum` | Statistic to apply to the alarm's associated metric | No | | ||
| `metric_threshold` | `1` | Value against which the specified statistic is compared | No | | ||
| `default_alarm_action` | `action/actions/AWS_EC2.InstanceId.Reboot/1.0` | String of action to execute when this alarm transitions into an ALARM state | No | | ||
| `user_data` | `[]` | `User Data` which be concated with `terraform-template-User Data-github-authorized-keys`. Conflicts with `custom_user_data` | No | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terraform-template-user-data-github-authorized-keys
variables.tf
Outdated
} | ||
|
||
variable "user_data" { | ||
description = "User data to provide when launching the instance" | ||
description = "User Data which be concated with `terraform-template-User Data-github-authorized-keys`" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
terraform-template-user-data-github-authorized-keys
main.tf
Outdated
@@ -7,6 +7,7 @@ locals { | |||
availability_zone = "${var.availability_zone != "" ? var.availability_zone : data.aws_subnet.default.availability_zone}" | |||
ami = "${var.ami != "" ? var.ami : data.aws_ami.default.image_id}" | |||
root_volume_type = "${var.root_volume_type != "" ? var.root_volume_type : data.aws_ami.info.root_device_type}" | |||
user_data = "${length(var.custom_user_data) > 0 ? join("", var.custom_user_data) : join("", data.template_file.user_data.*.rendered)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use var.custom_user_data
instead of join("", var.custom_user_data)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case will be error during plan\apply, because trueval\falseeval should be string
user_data.tf
Outdated
@@ -1,4 +1,5 @@ | |||
data "template_file" "user_data" { | |||
count = "${local.instance_count && length(var.custom_user_data) == 0 ? 1 : 0}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use local.instance_count == 0
.
value = "${zipmap(aws_network_interface.additional.*.id, aws_eip.additional.*.public_ip)}" | ||
} | ||
|
||
output "additional_eni_private" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example it need in sth for template rendering
We are overloading this module. Enforcing a convention on the user data that including using Closing this in favor of #22 |
What
User Data
Why
AMIs
doesn't support classicUser Data