in resources/registration-service/src/main/java/com/amazon/aws/partners/saasfactory/RegistrationService.java [81:188]
public RegistrationService() {
this.ssm = SsmClient.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
GetParametersResponse ssmBatch1 = this.ssm.getParameters(request -> request
.names("API_GW", "WORKSHOP_BUCKET", "KEY_PAIR", "VPC", "APP_SG","PRIVATE_SUBNETS")
);
for (software.amazon.awssdk.services.ssm.model.Parameter parameter : ssmBatch1.parameters()) {
switch (parameter.name()) {
case "API_GW":
this.apiGatewayEndpoint = parameter.value();
LOGGER.info("Setting env api gateway = " + this.apiGatewayEndpoint);
break;
case "WORKSHOP_BUCKET":
this.workshopBucket = parameter.value();
LOGGER.info("Setting env workshop bucket = " + this.workshopBucket);
break;
case "KEY_PAIR":
this.keyPairName = parameter.value();
LOGGER.info("Setting env key pair name = " + this.keyPairName);
break;
case "VPC":
this.vpcId = parameter.value();
LOGGER.info("Setting env vpc = " + this.vpcId);
break;
case "APP_SG":
this.applicationServerSecurityGroup = parameter.value();
LOGGER.info("Setting env app server security group = " + this.applicationServerSecurityGroup);
break;
case "PRIVATE_SUBNETS":
this.privateSubnetIds = parameter.value();
LOGGER.info("Setting env private subnets = " + this.privateSubnetIds);
break;
}
}
// Can only query for a max of 10 parameters at a time...
GetParametersResponse ssmBatch2 = this.ssm.getParameters(request -> request
.names("PIPELINE_BUCKET", "CODE_DEPLOY", "DEPLOYMENT_GROUP", "CODE_DEPLOY_LAMBDA", "ALB_LISTENER", "RDS_ADD_USER_LAMBDA")
);
for (software.amazon.awssdk.services.ssm.model.Parameter parameter : ssmBatch2.parameters()) {
switch (parameter.name()) {
case "PIPELINE_BUCKET":
this.codePipelineBucket = parameter.value();
LOGGER.info("Setting env codepipeline bucket = " + this.codePipelineBucket);
break;
case "CODE_DEPLOY":
this.codeDeployApplication = parameter.value();
LOGGER.info("Setting env codedeploy application = " + this.codeDeployApplication);
break;
case "DEPLOYMENT_GROUP":
this.deploymentGroup = parameter.value();
LOGGER.info("Setting env codedeploy deployment group = " + this.deploymentGroup);
break;
case "CODE_DEPLOY_LAMBDA":
this.updateCodeDeployLambdaArn = parameter.value();
LOGGER.info("Setting env update codedeploy lambda = " + this.updateCodeDeployLambdaArn);
break;
case "ALB_LISTENER":
this.albListenerArn = parameter.value();
LOGGER.info("Setting env alb listener = " + this.albListenerArn);
break;
case "RDS_ADD_USER_LAMBDA":
this.addDatabaseUserArn = parameter.value();
LOGGER.info("Setting env add db user = " + this.addDatabaseUserArn);
break;
}
}
if (this.apiGatewayEndpoint == null || this.apiGatewayEndpoint.isEmpty() ||
this.workshopBucket == null || this.workshopBucket.isEmpty() ||
this.keyPairName == null || this.keyPairName.isEmpty() ||
this.vpcId == null || this.vpcId.isEmpty() ||
this.applicationServerSecurityGroup == null || this.applicationServerSecurityGroup.isEmpty() ||
this.privateSubnetIds == null || this.privateSubnetIds.isEmpty() ||
this.codePipelineBucket == null || this.codePipelineBucket.isEmpty() ||
this.deploymentGroup == null || this.deploymentGroup.isEmpty() ||
this.updateCodeDeployLambdaArn == null || this.updateCodeDeployLambdaArn.isEmpty() ||
this.albListenerArn == null || this.albListenerArn.isEmpty() ||
this.addDatabaseUserArn == null || this.addDatabaseUserArn.isEmpty()
) {
throw new RuntimeException("Failed to get all required settings from Parameter Store!");
}
this.elbv2 = ElasticLoadBalancingV2Client.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
this.cfn = CloudFormationClient.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
this.cognito = CognitoIdentityProviderClient.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
this.ddb = DynamoDbClient.builder()
.httpClientBuilder(UrlConnectionHttpClient.builder())
.credentialsProvider(EnvironmentVariableCredentialsProvider.create())
.build();
}