Skip to content

Commit 1727653

Browse files
committed
Update key-pair module call to use latest version.
1 parent 0fac02b commit 1727653

File tree

2 files changed

+2
-177
lines changed

2 files changed

+2
-177
lines changed

README.md

Lines changed: 1 addition & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,3 @@
1-
# AWS EC2 Instance Terraform module
2-
3-
Terraform module which creates an EC2 instance on AWS.
4-
5-
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
6-
7-
## Usage
8-
9-
### Single EC2 Instance
10-
11-
```hcl
12-
module "ec2_instance" {
13-
source = "terraform-aws-modules/ec2-instance/aws"
14-
15-
name = "single-instance"
16-
17-
instance_type = "t2.micro"
18-
key_name = "user1"
19-
monitoring = true
20-
vpc_security_group_ids = ["sg-12345678"]
21-
subnet_id = "subnet-eddcdzz4"
22-
23-
tags = {
24-
Terraform = "true"
25-
Environment = "dev"
26-
}
27-
}
28-
```
29-
30-
### Multiple EC2 Instance
31-
32-
```hcl
33-
module "ec2_instance" {
34-
source = "terraform-aws-modules/ec2-instance/aws"
35-
36-
for_each = toset(["one", "two", "three"])
37-
38-
name = "instance-${each.key}"
39-
40-
instance_type = "t2.micro"
41-
key_name = "user1"
42-
monitoring = true
43-
vpc_security_group_ids = ["sg-12345678"]
44-
subnet_id = "subnet-eddcdzz4"
45-
46-
tags = {
47-
Terraform = "true"
48-
Environment = "dev"
49-
}
50-
}
51-
```
52-
53-
### Spot EC2 Instance
54-
55-
```hcl
56-
module "ec2_instance" {
57-
source = "terraform-aws-modules/ec2-instance/aws"
58-
59-
name = "spot-instance"
60-
61-
create_spot_instance = true
62-
spot_price = "0.60"
63-
spot_type = "persistent"
64-
65-
instance_type = "t2.micro"
66-
key_name = "user1"
67-
monitoring = true
68-
vpc_security_group_ids = ["sg-12345678"]
69-
subnet_id = "subnet-eddcdzz4"
70-
71-
tags = {
72-
Terraform = "true"
73-
Environment = "dev"
74-
}
75-
}
76-
```
77-
78-
## Module wrappers
79-
80-
Users of this Terraform module can create multiple similar resources by using [`for_each` meta-argument within `module` block](https://www.terraform.io/language/meta-arguments/for_each) which became available in Terraform 0.13.
81-
82-
Users of Terragrunt can achieve similar results by using modules provided in the [wrappers](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/wrappers) directory, if they prefer to reduce amount of configuration files.
83-
84-
## Examples
85-
86-
- [Complete EC2 instance](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/complete)
87-
- [EC2 instance w/ private network access via Session Manager](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/session-manager)
88-
- [EC2 instance with EBS volume attachment](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/volume-attachment)
89-
90-
## Make an encrypted AMI for use
91-
92-
This module does not support encrypted AMI's out of the box however it is easy enough for you to generate one for use
93-
94-
This example creates an encrypted image from the latest ubuntu 16.04 base image.
95-
96-
```hcl
97-
provider "aws" {
98-
region = "us-west-2"
99-
}
100-
101-
data "aws_ami" "ubuntu" {
102-
most_recent = true
103-
owners = ["679593333241"]
104-
105-
filter {
106-
name = "name"
107-
values = ["ubuntu-minimal/images/hvm-ssd/ubuntu-focal-20.04-*"]
108-
}
109-
110-
filter {
111-
name = "virtualization-type"
112-
values = ["hvm"]
113-
}
114-
}
115-
116-
resource "aws_ami_copy" "ubuntu_encrypted_ami" {
117-
name = "ubuntu-encrypted-ami"
118-
description = "An encrypted root ami based off ${data.aws_ami.ubuntu.id}"
119-
source_ami_id = data.aws_ami.ubuntu.id
120-
source_ami_region = "eu-west-2"
121-
encrypted = true
122-
123-
tags = { Name = "ubuntu-encrypted-ami" }
124-
}
125-
126-
data "aws_ami" "encrypted-ami" {
127-
most_recent = true
128-
129-
filter {
130-
name = "name"
131-
values = [aws_ami_copy.ubuntu_encrypted_ami.id]
132-
}
133-
134-
owners = ["self"]
135-
}
136-
```
137-
138-
## Conditional creation
139-
140-
The following combinations are supported to conditionally create resources:
141-
142-
- Disable resource creation (no resources created):
143-
144-
```hcl
145-
create = false
146-
```
147-
148-
- Create spot instance:
149-
150-
```hcl
151-
create_spot_instance = true
152-
```
153-
154-
## Notes
155-
156-
- `network_interface` can't be specified together with `vpc_security_group_ids`, `associate_public_ip_address`, `subnet_id`. See [complete example](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/complete) for details.
157-
- Changes in `ebs_block_device` argument will be ignored. Use [aws_volume_attachment](https://www.terraform.io/docs/providers/aws/r/volume_attachment.html) resource to attach and detach volumes from AWS EC2 instances. See [this example](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/examples/volume-attachment).
158-
- In regards to spot instances, you must grant the `AWSServiceRoleForEC2Spot` service-linked role access to any custom KMS keys, otherwise your spot request and instances will fail with `bad parameters`. You can see more details about why the request failed by using the awscli and `aws ec2 describe-spot-instance-requests`
159-
160-
<!-- BEGIN_TF_DOCS -->
1611
## Requirements
1622

1633
| Name | Version |
@@ -175,7 +15,7 @@ The following combinations are supported to conditionally create resources:
17515

17616
| Name | Source | Version |
17717
|------|--------|---------|
178-
| <a name="module_key-pair"></a> [key-pair](#module\_key-pair) | app.terraform.io/sccm/key-pair-creation/aws | 0.0.1 |
18+
| <a name="module_key-pair"></a> [key-pair](#module\_key-pair) | app.terraform.io/sccm/key-pair-creation/aws | 0.0.4 |
17919

18020
## Resources
18121

@@ -304,18 +144,3 @@ The following combinations are supported to conditionally create resources:
304144
| <a name="output_spot_instance_id"></a> [spot\_instance\_id](#output\_spot\_instance\_id) | The Instance ID (if any) that is currently fulfilling the Spot Instance request |
305145
| <a name="output_spot_request_state"></a> [spot\_request\_state](#output\_spot\_request\_state) | The current request state of the Spot Instance Request |
306146
| <a name="output_tags_all"></a> [tags\_all](#output\_tags\_all) | A map of tags assigned to the resource, including those inherited from the provider default\_tags configuration block |
307-
<!-- END_TF_DOCS -->
308-
309-
## Authors
310-
311-
Module is maintained by [Anton Babenko](https://github.com/antonbabenko) with help from [these awesome contributors](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/graphs/contributors).
312-
313-
## License
314-
315-
Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/tree/master/LICENSE) for full details.
316-
317-
## Additional information for users from Russia and Belarus
318-
319-
* Russia has [illegally annexed Crimea in 2014](https://en.wikipedia.org/wiki/Annexation_of_Crimea_by_the_Russian_Federation) and [brought the war in Donbas](https://en.wikipedia.org/wiki/War_in_Donbas) followed by [full-scale invasion of Ukraine in 2022](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine).
320-
* Russia has brought sorrow and devastations to millions of Ukrainians, killed hundreds of innocent people, damaged thousands of buildings, and forced several million people to flee.
321-
* [Putin khuylo!](https://en.wikipedia.org/wiki/Putin_khuylo!)

key-pair.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module "key-pair" {
22
source = "app.terraform.io/sccm/key-pair-creation/aws"
3-
version = "0.0.1"
3+
version = "0.0.4"
44

55
key_pair_name = var.key_name
66
}

0 commit comments

Comments
 (0)