Skip to content

Commit 80b74fd

Browse files
Merge pull request #1 from StoneCastle-Cash-Management/SCE-345-module-customizations
SCE-345 - Add KP And Set Default LT to EC2 Module
2 parents 6f851d8 + f9e708f commit 80b74fd

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

examples/customizations/main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module "instance" {
2+
source = "../../"
3+
4+
name = "example name"
5+
instance_type = "r5.large"
6+
ami = "ami-04426a869f59d0d45"
7+
key_name = "example_key"
8+
vpc_security_group_ids = ["sg-07b4edce8a1a6eb24"]
9+
subnet_id = "subnet-067f45f707b2dc297"
10+
root_block_device = [
11+
{
12+
encrypted = true
13+
kms_key_id = "arn:aws:kms:us-east-1:521938783116:key/e3203821-6efd-4848-9a8c-50a9990e06cd"
14+
}
15+
]
16+
}
17+

examples/customizations/versions.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.66"
8+
}
9+
}
10+
}
11+
12+
provider "aws" {
13+
region = "us-east-1"
14+
}

key-pair.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module "key-pair" {
2+
source = "app.terraform.io/sccm/key-pair-creation/aws"
3+
version = "0.0.1"
4+
5+
key_pair_name = var.key_name
6+
}

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ resource "aws_instance" "this" {
3535
subnet_id = var.subnet_id
3636
vpc_security_group_ids = var.vpc_security_group_ids
3737

38-
key_name = var.key_name
38+
key_name = module.key-pair.key_pair_name
3939
monitoring = var.monitoring
4040
get_password_data = var.get_password_data
4141
iam_instance_profile = var.create_iam_instance_profile ? aws_iam_instance_profile.this[0].name : var.iam_instance_profile
@@ -213,7 +213,7 @@ resource "aws_instance" "ignore_ami" {
213213
subnet_id = var.subnet_id
214214
vpc_security_group_ids = var.vpc_security_group_ids
215215

216-
key_name = var.key_name
216+
key_name = module.key-pair.key_pair_name
217217
monitoring = var.monitoring
218218
get_password_data = var.get_password_data
219219
iam_instance_profile = var.create_iam_instance_profile ? aws_iam_instance_profile.this[0].name : var.iam_instance_profile
@@ -397,7 +397,7 @@ resource "aws_spot_instance_request" "this" {
397397
subnet_id = var.subnet_id
398398
vpc_security_group_ids = var.vpc_security_group_ids
399399

400-
key_name = var.key_name
400+
key_name = module.key-pair.key_pair_name
401401
monitoring = var.monitoring
402402
get_password_data = var.get_password_data
403403
iam_instance_profile = var.create_iam_instance_profile ? aws_iam_instance_profile.this[0].name : var.iam_instance_profile

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ variable "host_id" {
109109
variable "iam_instance_profile" {
110110
description = "IAM Instance Profile to launch the instance with. Specified as the name of the Instance Profile"
111111
type = string
112-
default = null
112+
default = "EC2DefaultProfile"
113113
}
114114

115115
variable "instance_initiated_shutdown_behavior" {

0 commit comments

Comments
 (0)