Skip to content

Commit d60499e

Browse files
committed
added cloud-init based password config to official ubuntu config.
1 parent de9f64e commit d60499e

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#cloud-config
2+
ssh_pwauth: true
3+
chpasswd:
4+
list: |
5+
ubuntu:%%PASSWORD%%
6+
expire: false

assets/terraform/aws/ec2_instance/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ resource "aws_instance" "ubuntu_instance" {
3636
instance_type = var.instance_type
3737
key_name = var.keypair_name
3838
subnet_id = data.aws_subnet.app_subnet.id
39+
user_data = replace(file("${path.module}/cloud-init.yaml"), "%%PASSWORD%%", var.ubuntu_password)
3940
vpc_security_group_ids = [ aws_security_group.ubuntu_Security_Group.id, var.default_security_group_id ]
4041
}
4142

assets/terraform/aws/ec2_instance/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ variable "inbound_port" {
3030
type = string
3131
default = "80"
3232
}
33+
34+
variable "ubuntu_password" {
35+
36+
}

blueprints/Weather App on EC2 Web Server.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ grains:
4747
- instance_type: 't3a.medium'
4848
- keypair_name: 'TorqueSandbox'
4949
- inbound_port: "80"
50+
- ubuntu_password: 'Quali@AWS'
5051
env-vars: []
5152
outputs:
5253
- instance-port-link

0 commit comments

Comments
 (0)