Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
terraform [2020/02/18 14:22] jsanders |
terraform [2020/02/19 14:33] (current) jsanders |
||
---|---|---|---|
Line 3: | Line 3: | ||
==== Provider Configuration ==== | ==== Provider Configuration ==== | ||
=== Generic Provider === | === Generic Provider === | ||
- | //see:// [[https://www.terraform.io/docs/configuration/providers.html|Providers - Configuration Language - Terraform by Hashicorp]]\\ | + | //see also:// [[https://www.terraform.io/docs/configuration/providers.html|Providers - Configuration Language - Terraform by Hashicorp]]\\ |
\\ | \\ | ||
=== AWS === | === AWS === | ||
Line 43: | Line 43: | ||
} | } | ||
If specifying the profile through the ''AWS_PROFILE'' environment variable, you may also need to set ''AWS_SDK_LOAD_CONFIG'' to a truthy value (e.g. ''AWS_SDK_LOAD_CONFIG=1'') for advanced AWS client configurations, such as profiles that use the ''source_profile'' or ''role_arn'' configurations. | If specifying the profile through the ''AWS_PROFILE'' environment variable, you may also need to set ''AWS_SDK_LOAD_CONFIG'' to a truthy value (e.g. ''AWS_SDK_LOAD_CONFIG=1'') for advanced AWS client configurations, such as profiles that use the ''source_profile'' or ''role_arn'' configurations. | ||
- | \\ | + | ==== Adding User Data in Configs ==== |
+ | To add a user data file into a startup/config script, first store your script in a server-accessible location, then create a file named ''userdata.txt'' using the following template: | ||
+ | <powershell> | ||
+ | C:\\Path\\To\\Your\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule | ||
+ | </powershell> | ||
+ | You can then launch the instance by specifying the text file containing pointers to your script(s): | ||
+ | resource "aws_instance" "my-test-instance" { | ||
+ | ami = "${data.aws_ami.ec2-worker-initial-encrypted-ami.id}" | ||
+ | instance_type = "t2.micro" | ||
+ | |||
+ | tags { | ||
+ | Name = "my-test-instance" | ||
+ | } | ||
+ | |||
+ | user_data = "${file(userdata.txt)}" | ||
+ | } | ||
==== Selected Documentation ==== | ==== Selected Documentation ==== | ||
- [[https://www.terraform.io/docs/providers/aws/index.html#argument-reference|Provider: AWS - Argument Reference]] - These arguments, along with the [[terraform#generic_provider|generic provider arguments]], are supported in the AWS Provider block | - [[https://www.terraform.io/docs/providers/aws/index.html#argument-reference|Provider: AWS - Argument Reference]] - These arguments, along with the [[terraform#generic_provider|generic provider arguments]], are supported in the AWS Provider block |