@@ -25,14 +25,6 @@ module "label" {
2525 name = " ${ var . name } "
2626}
2727
28- # Apply the tf_github_authorized_keys module for this resource
29- module "github_authorized_keys" {
30- source = " git::https://github.com/cloudposse/tf_github_authorized_keys.git?ref=tags/0.1.0"
31- github_api_token = " ${ var . github_api_token } "
32- github_organization = " ${ var . github_organization } "
33- github_team = " ${ var . github_team } "
34- }
35-
3628resource "aws_iam_instance_profile" "default" {
3729 name = " ${ module . label . id } "
3830 role = " ${ aws_iam_role . default . name } "
@@ -71,11 +63,29 @@ resource "aws_security_group" "default" {
7163 }
7264}
7365
66+ # Apply the tf_github_authorized_keys module for this resource
67+ module "github_authorized_keys" {
68+ source = " git::https://github.com/cloudposse/tf_github_authorized_keys.git?ref=tags/0.1.0"
69+ github_api_token = " ${ var . github_api_token } "
70+ github_organization = " ${ var . github_organization } "
71+ github_team = " ${ var . github_team } "
72+ }
73+
74+ data "template_file" "user_data" {
75+ template = " ${ file (" ${ path . module } /user_data.sh" )} "
76+
77+ vars {
78+ user_data = " ${ join (" \n " , compact (concat (var. user_data , list (module. github_authorized_keys . user_data ))))} "
79+ welcome_message = " ${ var . welcome_message } "
80+ ssh_user = " ${ var . ssh_user } "
81+ }
82+ }
83+
7484resource "aws_instance" "default" {
7585 ami = " ${ var . ec2_ami } "
7686 instance_type = " ${ var . instance_type } "
7787
78- user_data = " ${ module . github_authorized_keys . user_data } "
88+ user_data = " ${ data . template_file . user_data . rendered } "
7989
8090 vpc_security_group_ids = [
8191 " ${ compact (concat (list (aws_security_group. default . id ), var. security_groups ))} "
@@ -103,7 +113,7 @@ resource "aws_eip" "default" {
103113
104114# Apply the provisioner module for this resource
105115module "ansible" {
106- source = " git::https://github.com/cloudposse/tf_ansible.git?ref=tags/0.2 .0"
116+ source = " git::https://github.com/cloudposse/tf_ansible.git?ref=tags/0.3 .0"
107117 arguments = " ${ var . ansible_arguments } "
108118 envs = [" host=${ aws_eip . default . public_ip } " ]
109119 playbook = " ${ var . ansible_playbook } "
0 commit comments