@@ -246,6 +246,7 @@ aws s3 cp "$localhome"/config.tar.gz s3://"$bucketname"
246246rm -f config.tar.gz
247247
248248echo " Copying script files to new bucket"
249+ sed -i " s/secret_name/RL-RG-$runid -$env /g" " $localhome " /scripts/connect-db.sh
249250tar -czf scripts.tar.gz scripts/*
250251tar -tf scripts.tar.gz
251252aws s3 cp " $localhome " /scripts.tar.gz s3://" $bucketname "
@@ -337,10 +338,10 @@ function create_cognito_pool() {
337338function create_doc_db() {
338339 echo " Creating new stack $1 "
339340 aws cloudformation deploy --template-file " $localhome " /rg_document_db.yml --stack-name " $1 " \
340- --parameter-overrides MasterUser= " $appuser " MasterPassword= " $appuserpassword " \
341+ --parameter-overrides DocDBSecretName= " RL-RG- $runid - $env " VpceSecurityGroupName= " RGVE-SG- $runid " \
341342 DBClusterName=" RGCluster-$runid " DBInstanceName=" RGInstance-$runid " DBInstanceClass=" db.t3.medium" \
342343 Subnet1=" $subnet1id " Subnet2=" $subnet2id " Subnet3=" $subnet3id " VPC=" $vpcid " \
343- SecurityGroupName=" RGDB-SG-$runid " DocDBSubnetGroupName=" RGDBSubnet-$runid "
344+ SecurityGroupName=" RGDB-SG-$runid " DocDBSubnetGroupName=" RGDBSubnet-$runid " --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND
344345 echo " Waiting for stack $1 to finish deploying..."
345346 aws cloudformation wait stack-create-complete --stack-name " $1 "
346347}
@@ -355,6 +356,7 @@ function create_image_builder() {
355356
356357}
357358
359+
358360function create_main_stack() {
359361 echo " Creating new stack $1 "
360362 # update the AMI id in the RGMainStack CFT
@@ -366,14 +368,14 @@ function create_main_stack() {
366368 echo " UserPool ClientId: $userpoolclient_id "
367369 echo " BucketName $bucketname "
368370 echo " RG URL: $rgurl "
369- if [ -n " $appuserpassword " ]; then
371+ if [ -n " $secpassword " ]; then
370372 echo " UserPassword is not a blank string"
371373 fi
372374 if [ -n " $adminpassword " ]; then
373375 echo " AdminPassword is not a blank string"
374376 fi
375377 echo " VPC Id: $vpcid "
376- echo " subnet1id: subnet1id"
378+ echo " subnet1id: $ subnet1id"
377379 echo " Key Pair: $keypairname "
378380 echo " TGARN: $tgarn "
379381 echo " DocDBURL: $docdburl "
@@ -382,7 +384,7 @@ function create_main_stack() {
382384 aws cloudformation deploy --template-file " $localhome " /rg_main_stack.yml \
383385 --stack-name " $mainstackname " \
384386 --parameter-overrides CFTBucketName=" $bucketname " RGUrl=" $rgurl " \
385- UserPassword=" $appuserpassword " AdminPassword=" $adminpassword " \
387+ UserPassword=" $secpassword " AdminPassword=" $adminpassword " \
386388 VPC=" $vpcid " Subnet1=" $subnet1id " KeyName1=" $keypairname " TGARN=" $tgarn " \
387389 DocumentDBInstanceURL=" $docdburl " Environment=" $env " BaseAccountPolicyName=" RG-Portal-Base-Account-Policy-$env -$runid " \
388390 --capabilities CAPABILITY_NAMED_IAM
@@ -506,12 +508,14 @@ ac_name=$(aws sts get-caller-identity --query "Account" --output text)
506508r53_domain_name=" ${rgurl// http[s]*: \/\/ / } "
507509jqcmd=' .HostedZones[] | select(.Name==' " \" ${r53_domain_name} .\" " ' )|.Id'
508510hosted_zone=$( aws route53 list-hosted-zones-by-name --dns-name " $r53_domain_name " | jq -r " $jqcmd " | sed -e ' s#\/hostedzone\/##' )
511+ secretdb_arn=$( aws secretsmanager get-secret-value --secret-id RL-RG-$runid -$env | jq --raw-output .ARN)
509512echo " Creating configs locally"
510513export RG_ENV=" $env "
511514./makeconfigs.sh " $userpool_id " " $userpoolclient_id " " $bucketname " " $appuser " " $appuserpassword " \
512- " $runid " " $rgurl " " $region " " ROLE_NAME" " $ac_name " " $hosted_zone "
515+ " $runid " " $rgurl " " $region " " ROLE_NAME" " $ac_name " " $hosted_zone " " $secretdb_arn "
513516echo " Uploading configs to $bucketname "
514517aws s3 cp " $localhome " /config.tar.gz s3://" $bucketname "
518+ secpassword=$( aws secretsmanager get-secret-value --secret-id RL-RG-$runid -$env --version-stage AWSCURRENT | jq --raw-output .SecretString| jq -r ." password" )
515519# ===============================================================================================================
516520# Creating Main stack
517521echo " Deploying main stack (roles, ec2 instance etc.)"
0 commit comments