-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb56bc6
commit 5e8b4d7
Showing
15 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
# Local Variables declaration | ||
locals { | ||
name = "key" | ||
region = "us-east-2" | ||
aws_region = "us-east-2" | ||
environment = "prod" | ||
additional_tags = { | ||
tags = { | ||
Environment = "stg" | ||
Name = "key_pair" | ||
cost = format("%s-%s-kp", local.environment, local.name) | ||
} | ||
additional_aws_tags = { | ||
Owner = "organization_name" | ||
Expires = "Never" | ||
Department = "Engineering" | ||
} | ||
} | ||
|
||
# Using "squareops/keypair/aws" module to generate an EC2 key pair and storing it in ssm parameter store. | ||
module "key_pair" { | ||
source = "squareops/keypair/aws" | ||
key_name = format("%s-%s-kp", local.environment, local.name) | ||
version = "1.0.2" | ||
key_pair_name = format("%s-%s-kp", local.environment, local.name) | ||
environment = local.environment | ||
ssm_parameter_path = format("%s-%s-ssm", local.environment, local.name) #SSM parameter secret name | ||
tags = local.tags | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
provider "aws" { | ||
region = local.region | ||
region = local.aws_region | ||
default_tags { | ||
tags = local.additional_tags | ||
tags = local.additional_aws_tags | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
# Module block for creating an EC2 key pair | ||
module "key_pair" { | ||
source = "terraform-aws-modules/key-pair/aws" | ||
version = "2.0.0" | ||
key_name = var.key_name | ||
create_private_key = true | ||
version = "2.0.3" | ||
key_name = var.key_pair_name | ||
create_private_key = var.create_private_key | ||
tags = var.tags | ||
} | ||
|
||
|
||
# Resource block for storing the private key in AWS Systems Manager Parameter Store | ||
resource "aws_ssm_parameter" "ssm_ec2_keypair" { | ||
name = var.ssm_parameter_path | ||
description = "Stores the private key of ec2 key pair" | ||
type = "SecureString" | ||
value = module.key_pair.private_key_pem | ||
tags = { | ||
Environment = var.environment | ||
Name = var.ssm_parameter_path | ||
} | ||
tags = var.tags | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.