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
a49d57a3
Unverified
Commit
a49d57a3
authored
Jun 04, 2018
by
Anton Babenko
Committed by
GitHub
Jun 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for CPU credits (#35)
* Added support for CPU credits * Updated formatting
parent
c269860b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
4 deletions
+26
-4
.pre-commit-config.yaml
.pre-commit-config.yaml
+2
-2
README.md
README.md
+2
-0
README.md
examples/basic/README.md
+1
-0
outputs.tf
examples/basic/outputs.tf
+5
-0
main.tf
main.tf
+6
-2
outputs.tf
outputs.tf
+5
-0
variables.tf
variables.tf
+5
-0
No files found.
.pre-commit-config.yaml
View file @
a49d57a3
repos
:
repos
:
-
repo
:
git://github.com/antonbabenko/pre-commit-terraform
-
repo
:
git://github.com/antonbabenko/pre-commit-terraform
rev
:
v1.7.
0
rev
:
v1.7.
3
hooks
:
hooks
:
-
id
:
terraform_fmt
-
id
:
terraform_fmt
-
id
:
terraform_docs
-
id
:
terraform_docs
-
repo
:
git://github.com/pre-commit/pre-commit-hooks
-
repo
:
git://github.com/pre-commit/pre-commit-hooks
rev
:
v1.
2.3
rev
:
v1.
3.0
hooks
:
hooks
:
-
id
:
check-merge-conflict
-
id
:
check-merge-conflict
README.md
View file @
a49d57a3
...
@@ -89,6 +89,7 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -89,6 +89,7 @@ data "aws_ami" "ubuntu-xenial" {
|------|-------------|:----:|:-----:|:-----:|
|------|-------------|:----:|:-----:|:-----:|
| ami | ID of AMI to use for the instance | string | - | yes |
| ami | ID of AMI to use for the instance | string | - | yes |
| associate_public_ip_address | If true, the EC2 instance will have associated public IP address | string |
`false`
| no |
| associate_public_ip_address | If true, the EC2 instance will have associated public IP address | string |
`false`
| no |
| cpu_credits | The credit option for CPU usage (unlimited or standard) | string |
`standard`
| no |
| disable_api_termination | If true, enables EC2 Instance Termination Protection | string |
`false`
| no |
| disable_api_termination | If true, enables EC2 Instance Termination Protection | string |
`false`
| no |
| ebs_block_device | Additional EBS block devices to attach to the instance | string |
`<list>`
| no |
| ebs_block_device | Additional EBS block devices to attach to the instance | string |
`<list>`
| no |
| ebs_optimized | If true, the launched EC2 instance will be EBS-optimized | string |
`false`
| no |
| ebs_optimized | If true, the launched EC2 instance will be EBS-optimized | string |
`false`
| no |
...
@@ -119,6 +120,7 @@ data "aws_ami" "ubuntu-xenial" {
...
@@ -119,6 +120,7 @@ data "aws_ami" "ubuntu-xenial" {
| Name | Description |
| Name | Description |
|------|-------------|
|------|-------------|
| availability_zone | List of availability zones of instances |
| availability_zone | List of availability zones of instances |
| credit_specification | List of credit specification of instances |
| id | List of IDs of instances |
| id | List of IDs of instances |
| key_name | List of key names of instances |
| key_name | List of key names of instances |
| network_interface_id | List of IDs of the network interface of instances |
| network_interface_id | List of IDs of the network interface of instances |
...
...
examples/basic/README.md
View file @
a49d57a3
...
@@ -24,6 +24,7 @@ Note that this example may create resources which can cost money. Run `terraform
...
@@ -24,6 +24,7 @@ Note that this example may create resources which can cost money. Run `terraform
| Name | Description |
| Name | Description |
|------|-------------|
|------|-------------|
| credit_specification | Credit specification of EC2 instance |
| id | List of IDs of instances |
| id | List of IDs of instances |
| instance_id | EC2 instance ID |
| instance_id | EC2 instance ID |
| instance_public_dns | Public DNS name assigned to the EC2 instance |
| instance_public_dns | Public DNS name assigned to the EC2 instance |
...
...
examples/basic/outputs.tf
View file @
a49d57a3
...
@@ -17,3 +17,8 @@ output "instance_public_dns" {
...
@@ -17,3 +17,8 @@ output "instance_public_dns" {
description
=
"Public DNS name assigned to the EC2 instance"
description
=
"Public DNS name assigned to the EC2 instance"
value
=
"
${module
.
ec2
.
public_dns
[
0
]
}
"
value
=
"
${module
.
ec2
.
public_dns
[
0
]
}
"
}
}
output
"credit_specification"
{
description
=
"Credit specification of EC2 instance"
value
=
"
${module
.
ec2
.
credit_specification
[
0
]
}
"
}
main.tf
View file @
a49d57a3
######
######
# EC2 instance
# EC2 instance
#
# Note: network_interface can't be specified together with associate_public_ip_address
######
######
resource
"aws_instance"
"this"
{
resource
"aws_instance"
"this"
{
count
=
"
${
var
.
instance_count
}
"
count
=
"
${
var
.
instance_count
}
"
...
@@ -30,10 +32,12 @@ resource "aws_instance" "this" {
...
@@ -30,10 +32,12 @@ resource "aws_instance" "this" {
placement_group
=
"
${
var
.
placement_group
}
"
placement_group
=
"
${
var
.
placement_group
}
"
tenancy
=
"
${
var
.
tenancy
}
"
tenancy
=
"
${
var
.
tenancy
}
"
# Note: network_interface can't be specified together with associate_public_ip_address
credit_specification
{
# network_interface = "${var.network_interface}"
cpu_credits
=
"
${
var
.
cpu_credits
}
"
}
tags
=
"
${
merge
(
var
.
tags
,
map
(
"Name"
,
var
.
instance_count
>
1
?
format
(
"%s-%d"
,
var
.
name
,
count
.
index
+
1
)
:
var
.
name
))
}
"
tags
=
"
${
merge
(
var
.
tags
,
map
(
"Name"
,
var
.
instance_count
>
1
?
format
(
"%s-%d"
,
var
.
name
,
count
.
index
+
1
)
:
var
.
name
))
}
"
lifecycle
{
lifecycle
{
# Due to several known issues in Terraform AWS provider related to arguments of aws_instance:
# 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)
# (eg, https://github.com/terraform-providers/terraform-provider-aws/issues/2036)
...
...
outputs.tf
View file @
a49d57a3
...
@@ -64,6 +64,11 @@ output "subnet_id" {
...
@@ -64,6 +64,11 @@ output "subnet_id" {
value
=
[
"
${
aws_instance
.
this
.
*
.
subnet_id
}
"
]
value
=
[
"
${
aws_instance
.
this
.
*
.
subnet_id
}
"
]
}
}
output
"credit_specification"
{
description
=
"List of credit specification of instances"
value
=
[
"
${
aws_instance
.
this
.
*
.
credit_specification
}
"
]
}
output
"tags"
{
output
"tags"
{
description
=
"List of tags of instances"
description
=
"List of tags of instances"
value
=
[
"
${
aws_instance
.
this
.
*
.
tags
}
"
]
value
=
[
"
${
aws_instance
.
this
.
*
.
tags
}
"
]
...
...
variables.tf
View file @
a49d57a3
...
@@ -123,3 +123,8 @@ variable "network_interface" {
...
@@ -123,3 +123,8 @@ variable "network_interface" {
description
=
"Customize network interfaces to be attached at instance boot time"
description
=
"Customize network interfaces to be attached at instance boot time"
default
=
[]
default
=
[]
}
}
variable
"cpu_credits"
{
description
=
"The credit option for CPU usage (unlimited or standard)"
default
=
"standard"
}
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