File tree Expand file tree Collapse file tree 3 files changed +22
-11
lines changed
03-scalable-java-app/ansible Expand file tree Collapse file tree 3 files changed +22
-11
lines changed Original file line number Diff line number Diff line change 11import boto3
22import json
33
4- secrets_client = boto3 .client ('secretsmanager' )
4+ region = 'us-west-2'
5+
6+ parameter_store = '/dev/petclinic/rds_endpoint'
57
68secret_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
1018response = secrets_client .get_secret_value (SecretId = secret_name )
1119
1220secret_value = response ['SecretString' ]
1321
1422database_details = json .loads (secret_value )
1523
16- file_path = "/home/ubuntu/application.properties"
17-
1824with 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 } " )
2228file_contents = file_contents .replace ("spring.datasource.username=petclinic" , f"spring.datasource.username={ database_details ['username' ]} " )
2329file_contents = file_contents .replace ("spring.datasource.password=petclinic" , f"spring.datasource.password={ database_details ['password' ]} " )
2430
25-
2631with open (file_path , 'w' ) as f :
2732 f .write (file_contents )
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments