Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-aws-ec2-instance
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Terraform Modules
terraform-aws-ec2-instance
Commits
00ee191f
Commit
00ee191f
authored
Dec 08, 2017
by
Anton Babenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make module idempotent by requiring subnet_id and ignore changes in several arguments (fixes #10)
parent
0a9253a5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
main.tf
examples/basic/main.tf
+1
-0
main.tf
main.tf
+6
-1
variables.tf
variables.tf
+0
-6
No files found.
examples/basic/main.tf
View file @
00ee191f
...
@@ -51,6 +51,7 @@ module "ec2" {
...
@@ -51,6 +51,7 @@ module "ec2" {
name
=
"example"
name
=
"example"
ami
=
"
${data
.
aws_ami
.
amazon_linux
.
id
}
"
ami
=
"
${data
.
aws_ami
.
amazon_linux
.
id
}
"
instance_type
=
"t2.micro"
instance_type
=
"t2.micro"
subnet_id
=
"
${
element
(
data
.
aws_subnet_ids
.
all
.
ids
,
0
)
}
"
vpc_security_group_ids
=
[
"
${module
.
security_group
.
this_security_group_id
}
"
]
vpc_security_group_ids
=
[
"
${module
.
security_group
.
this_security_group_id
}
"
]
associate_public_ip_address
=
true
associate_public_ip_address
=
true
}
}
main.tf
View file @
00ee191f
...
@@ -27,7 +27,6 @@ resource "aws_instance" "this" {
...
@@ -27,7 +27,6 @@ resource "aws_instance" "this" {
source_dest_check
=
"
${
var
.
source_dest_check
}
"
source_dest_check
=
"
${
var
.
source_dest_check
}
"
disable_api_termination
=
"
${
var
.
disable_api_termination
}
"
disable_api_termination
=
"
${
var
.
disable_api_termination
}
"
instance_initiated_shutdown_behavior
=
"
${
var
.
instance_initiated_shutdown_behavior
}
"
instance_initiated_shutdown_behavior
=
"
${
var
.
instance_initiated_shutdown_behavior
}
"
availability_zone
=
"
${
var
.
availability_zone
}
"
placement_group
=
"
${
var
.
placement_group
}
"
placement_group
=
"
${
var
.
placement_group
}
"
tenancy
=
"
${
var
.
tenancy
}
"
tenancy
=
"
${
var
.
tenancy
}
"
...
@@ -35,4 +34,10 @@ resource "aws_instance" "this" {
...
@@ -35,4 +34,10 @@ resource "aws_instance" "this" {
# network_interface = "${var.network_interface}"
# network_interface = "${var.network_interface}"
tags
=
"
${
merge
(
var
.
tags
,
map
(
"Name"
,
format
(
"%s-%d"
,
var
.
name
,
count
.
index
+
1
)))
}
"
tags
=
"
${
merge
(
var
.
tags
,
map
(
"Name"
,
format
(
"%s-%d"
,
var
.
name
,
count
.
index
+
1
)))
}
"
lifecycle
{
# Due to several known issues in Terraform AWS provider related to arguments of aws_instance:
# (eg, https://github.com/terraform-providers/terraform-provider-aws/issues/2036)
# we have to ignore changes in the following arguments
ignore_changes
=
[
"private_ip"
,
"vpc_security_group_ids"
,
"root_block_device"
]
}
}
}
variables.tf
View file @
00ee191f
...
@@ -11,11 +11,6 @@ variable "ami" {
...
@@ -11,11 +11,6 @@ variable "ami" {
description
=
"ID of AMI to use for the instance"
description
=
"ID of AMI to use for the instance"
}
}
variable
"availability_zone"
{
description
=
"The AZ to start the instance in"
default
=
""
}
variable
"placement_group"
{
variable
"placement_group"
{
description
=
"The Placement Group to start the instance in"
description
=
"The Placement Group to start the instance in"
default
=
""
default
=
""
...
@@ -62,7 +57,6 @@ variable "vpc_security_group_ids" {
...
@@ -62,7 +57,6 @@ variable "vpc_security_group_ids" {
variable
"subnet_id"
{
variable
"subnet_id"
{
description
=
"The VPC Subnet ID to launch in"
description
=
"The VPC Subnet ID to launch in"
default
=
""
}
}
variable
"associate_public_ip_address"
{
variable
"associate_public_ip_address"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment