1919 esac
2020done
2121
22- if ! " $pflag "
22+ if " $pflag "
2323then
24- echo " -p not specified, using default..." >&2
25- PROFILE=" default"
24+ echo " using AWS profile $PROFILE ..." >&2
2625fi
27- REGION=$( aws configure get region --profile " $PROFILE " )
26+ REGION=$( aws configure get region ${PROFILE : + --profile " $PROFILE " } )
2827
29- ARTIFACTS_BUCKET=$( aws --region " $REGION " --profile " $PROFILE " ssm get-parameter --name " /sdlf/storage/rArtifactsBucket/dev" --query " Parameter.Value" --output text)
30- aws s3 cp " $DIRNAME /scripts/legislators-glue-job.py" " s3://$ARTIFACTS_BUCKET /artifacts/" --profile " $PROFILE "
28+ ARTIFACTS_BUCKET=$( aws --region " $REGION " ssm get-parameter --name " /sdlf/storage/rArtifactsBucket/dev" --query " Parameter.Value" --output text ${PROFILE : +--profile " $PROFILE " } )
29+ aws s3 cp " $DIRNAME /scripts/legislators-glue-job.py" " s3://$ARTIFACTS_BUCKET /artifacts/" ${PROFILE : + --profile " $PROFILE " }
3130
3231mkdir " $DIRNAME " /output
3332
3433function send_legislators()
3534{
3635 ORIGIN=" $DIRNAME /data/"
3736
38- RAW_BUCKET=$( aws --region " $REGION " --profile " $PROFILE " ssm get-parameter --name " /sdlf/storage/rRawBucket/dev" --query " Parameter.Value" --output text)
39- KMS_KEY=$( aws --region " $REGION " --profile " $PROFILE " ssm get-parameter --name " /sdlf/dataset/rKMSDataKey/dev" --query " Parameter.Value" --output text)
37+ RAW_BUCKET=$( aws --region " $REGION " ssm get-parameter --name " /sdlf/storage/rRawBucket/dev" --query " Parameter.Value" --output text ${PROFILE : +--profile " $PROFILE " } )
38+ KMS_KEY=$( aws --region " $REGION " ssm get-parameter --name " /sdlf/dataset/rKMSDataKey/dev" --query " Parameter.Value" --output text ${PROFILE : +--profile " $PROFILE " } )
4039
4140 S3_DESTINATION=s3://$RAW_BUCKET /
4241 COUNT=0
4342 for FILE in " $ORIGIN " /* .json;
4443 do
4544 (( COUNT++ )) || true
46- aws s3 cp " $FILE " " ${S3_DESTINATION} legislators/" --profile " $PROFILE " -- sse aws:kms --sse-kms-key-id " $KMS_KEY "
45+ aws s3 cp " $FILE " " ${S3_DESTINATION} legislators/" --sse aws:kms --sse-kms-key-id " $KMS_KEY " ${PROFILE : +--profile " $PROFILE " }
4746 echo " transferred $COUNT files"
4847 done
4948}
5049
51- VPC_SUPPORT=$( aws --region " $REGION " --profile " $PROFILE " ssm get-parameter --name " /SDLF/VPC/Enabled" --query " Parameter.Value" --output text 2> /dev/null)
50+ VPC_SUPPORT=$( aws --region " $REGION " ssm get-parameter --name " /SDLF/VPC/Enabled" --query " Parameter.Value" --output text ${PROFILE : +--profile " $PROFILE " } 2> /dev/null)
5251if [ -z " $VPC_SUPPORT " ]
5352then
54- aws --region " $REGION " --profile " $PROFILE " ssm put-parameter --name " /SDLF/VPC/Enabled" --value " false" --type String
53+ aws --region " $REGION " ssm put-parameter --name " /SDLF/VPC/Enabled" --value " false" --type String ${PROFILE : +--profile " $PROFILE " }
5554fi
5655
5756aws cloudformation package --template-file " $DIRNAME " /scripts/legislators-glue-job.yaml \
5857 --s3-bucket " $ARTIFACTS_BUCKET " \
59- --profile " $PROFILE " \
58+ ${PROFILE : + --profile " $PROFILE " } \
6059 --output-template-file " $DIRNAME " /output/packaged-template.yaml
6160
6261STACK_NAME=" sdlf-legislators-glue-job"
@@ -67,6 +66,6 @@ aws cloudformation deploy \
6766 --tags Framework=sdlf \
6867 --capabilities " CAPABILITY_NAMED_IAM" " CAPABILITY_AUTO_EXPAND" \
6968 --region " $REGION " \
70- --profile " $PROFILE " || exit 1
69+ ${PROFILE : + --profile " $PROFILE " } || exit 1
7170
7271send_legislators
0 commit comments