Skip to content

Commit 1ce82cc

Browse files
committed
update
1 parent e18d1a2 commit 1ce82cc

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
import boto3
22
import json
33

4-
secrets_client = boto3.client('secretsmanager')
4+
region = 'us-west-2'
5+
6+
parameter_store = '/dev/petclinic/rds_endpoint'
57

68
secret_name = "rds!db-8f23e7a9-e9f8-4b50-a059-f0e310e18134"
79

8-
endpoint_port= "database-1.cvgrek461osh.us-west-2.rds.amazonaws.com:3306"
10+
file_path = "/home/aswin/Documents/application.properties"
11+
12+
ssm = boto3.client('ssm', region_name=region)
13+
14+
redis_endpoint = ssm.get_parameter(Name=parameter_store)['Parameter']['Value']
15+
16+
secrets_client = boto3.client('secretsmanager')
917

1018
response = secrets_client.get_secret_value(SecretId=secret_name)
1119

1220
secret_value = response['SecretString']
1321

1422
database_details = json.loads(secret_value)
1523

16-
file_path = "/home/ubuntu/application.properties"
17-
1824
with open(file_path, 'r') as f:
1925
file_contents = f.read()
2026

21-
file_contents = file_contents.replace("spring.datasource.url=jdbc:mysql://localhost:3306/petclinic", f"spring.datasource.url={(endpoint_port)}")
27+
file_contents = file_contents.replace("spring.datasource.url=jdbc:mysql://localhost:3306/petclinic", f"spring.datasource.url={redis_endpoint}")
2228
file_contents = file_contents.replace("spring.datasource.username=petclinic", f"spring.datasource.username={database_details['username']}")
2329
file_contents = file_contents.replace("spring.datasource.password=petclinic", f"spring.datasource.password={database_details['password']}")
2430

25-
2631
with open(file_path, 'w') as f:
2732
f.write(file_contents)

03-scalable-java-app/ansible/roles/java/tasks/python.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@
1515
become: true
1616
pip:
1717
name: boto3
18-
state: present
18+
state: present
19+
20+
- name: Install AWS CLI using pip
21+
pip:
22+
name: awscli
23+
state: latest
24+
executable: pip3

03-scalable-java-app/ansible/vm.pkr.hcl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ build {
2727
}
2828

2929
provisioner "file" {
30-
source = "file/spring-petclinic.jar"
30+
source = "files/spring-petclinic.jar"
3131
destination = "/home/ubuntu/spring-petclinic.jar"
3232
}
3333

3434
provisioner "file" {
35-
source = "file/application.properties"
35+
source = "files/application.properties"
3636
destination = "/home/ubuntu/application.properties"
3737
}
3838

3939
provisioner "file" {
40-
source = "file/secret.py"
41-
destination = "/home/ubuntu/secret.py"
40+
source = "files/secret.py"
41+
destination = "/home/ubuntu/properties.py"
4242
}
4343

4444
}

0 commit comments

Comments
 (0)