File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed
terraform/account-wide-infrastructure Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ module "vpc" {
1111module "web" {
1212 source = " ../modules/ec2"
1313 instance_type = var. instance_type
14- instance_key = var. instance_key
1514 name_prefix = " nhsd-nrlf--dev"
1615
1716 subnet_id = module. vpc . subnet_id
Original file line number Diff line number Diff line change @@ -43,7 +43,3 @@ variable "instance_type" {
4343 description = " Type for EC2 Instance"
4444 default = " t2.micro"
4545}
46-
47- variable "instance_key" {
48- default = " PowerBIGateway"
49- }
Original file line number Diff line number Diff line change 22resource "aws_instance" "web" {
33 ami = data. aws_ami . windows-2019 . id
44 instance_type = var. instance_type
5- key_name = var . instance_key
5+ key_name = aws_key_pair . ec2_key_pair . key_name
66 subnet_id = var. subnet_id
77 security_groups = var. security_groups
88
@@ -13,3 +13,19 @@ resource "aws_instance" "web" {
1313 }
1414
1515}
16+
17+ # Key pair for RDP access
18+ resource "tls_private_key" "instance_key_pair" {
19+ algorithm = " RSA"
20+ }
21+
22+ resource "aws_key_pair" "ec2_key_pair" {
23+ key_name = " PowerBI-GateWay-Key"
24+ public_key = tls_private_key. instance_key_pair . public_key_openssh
25+ }
26+
27+ # Saving Key Pair for ssh login for Client if needed
28+ resource "local_file" "ssh_key" {
29+ filename = " ${ aws_key_pair . ec2_key_pair . key_name } .pem"
30+ content = tls_private_key. instance_key_pair . private_key_pem
31+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,5 @@ variable "name_prefix" {
33 description = " The prefix to apply to all resources in the module."
44}
55variable "instance_type" {}
6- variable "instance_key" {}
76variable "security_groups" {}
87variable "subnet_id" {}
You can’t perform that action at this time.
0 commit comments