in src/main/java/com/awsblog/queueing/cdk/CDK_App.java [44:107]
public static void main(final String argv[]) {
String configJsonFile = CONFIG_FILE_NAME;
System.out.printf("%n");
System.out.printf("***************************************************************%n");
System.out.printf("****************** CDK App - v1.10 ******************%n");
System.out.printf("***************************************************************%n");
App app = new App();
String credentialsProfile = (String)app.getNode().tryGetContext("aws-credentials-profile");
String awsRegion = (String)app.getNode().tryGetContext("aws-region");
System.out.printf("Options:%n");
System.out.printf(" >> Configuration filename: [%s]%n", configJsonFile);
if (Utils.checkIfNotNullAndNotEmptyString(credentialsProfile)) System.out.printf(" >> Credentials profile name: %s%n", credentialsProfile);
if (Utils.checkIfNotNullAndNotEmptyString(awsRegion)) System.out.printf(" >> AWS region: %s%n", awsRegion);
System.out.printf("---------------------------------------------------------------------------------%n");
Configuration config = Configuration.fromJSON(FileUtils.getFileFromResourcesAsString(configJsonFile));
Map<String, IRole> roles = new HashMap<>();
Map<String, IFunction> functions = new HashMap<>();
AWSCredentials credentials = new ProfileCredentialsProvider(credentialsProfile).getCredentials();
AWSSecurityTokenServiceClientBuilder stsBuilder = AWSSecurityTokenServiceClientBuilder.standard();
stsBuilder.withRegion(awsRegion);
stsBuilder.withCredentials(new AWSStaticCredentialsProvider(credentials));
AWSSecurityTokenService stsClient = stsBuilder.build();
GetCallerIdentityRequest request = new GetCallerIdentityRequest();
GetCallerIdentityResult response = stsClient.getCallerIdentity(request);
String awsAccountID = response.getAccount();
System.out.printf("AWS Account #: [%s]%n", awsAccountID);
// -------------------- copy JAR to S3
AmazonS3ClientBuilder s3builder = AmazonS3ClientBuilder.standard();
if (!Utils.checkIfNullObject(credentialsProfile)) s3builder.withCredentials(new AWSStaticCredentialsProvider(credentials));
if (!Utils.checkIfNullObject(awsRegion)) s3builder.withRegion(awsRegion);
AmazonS3 s3 = s3builder.build();
//copyJARsToS3(s3, config);
// ------------------- Build stacks using CDK
Environment env = Environment.builder()
.account(awsAccountID)
.region(awsRegion)
.build();
StackProps props = StackProps.builder()
.env(env)
.build();
new DynamoStack(app, "aws-blog-queue-dynamodb-stack", props, config, roles);
//new RoleStack(app, "aws-blog-queue-role-stack", props, config, roles);
//new LambdaStack(app, "aws-blog-queue-lambda-stack", props, config, roles, functions);
app.synth();
}