Skip to content

Commit 9e257f9

Browse files
committed
Renaming the base tenant onboarding stack listener to match the other
listeners. Updating the onboarding service to track multiple stacks.
1 parent 0461f45 commit 9e257f9

File tree

20 files changed

+511
-367
lines changed

20 files changed

+511
-367
lines changed

functions/onboarding-app-stack-listener/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/OnboardingAppStackListener.java

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public OnboardingAppStackListener() {
6060

6161
@Override
6262
public Object handleRequest(SNSEvent event, Context context) {
63-
LOGGER.info(Utils.toJson(event));
63+
//LOGGER.info(Utils.toJson(event));
6464

6565
List<SNSEvent.SNSRecord> records = event.getRecords();
6666
SNSEvent.SNS sns = records.get(0).getSNS();
@@ -140,13 +140,34 @@ public Object handleRequest(SNSEvent event, Context context) {
140140
Map.of("tenantId", tenantId, "resources", Utils.toJson(tenantResource))
141141
);
142142
}
143+
// } else if ("AWS::CloudFormation::Stack".equals(resourceType) && "rds".equals(logicalId)) {
144+
// //this is the rds sub-stack so get the cluster and instance ids
145+
// getRdsResources(physicalResourceId, tenantResources);
143146
}
144147
}
145148
} catch (SdkServiceException cfnError) {
146149
LOGGER.error("cfn:ListStackResources error", cfnError);
147150
LOGGER.error(Utils.getFullStackTrace(cfnError));
148151
throw cfnError;
149152
}
153+
154+
// // Persist the tenant specific things as tenant settings
155+
// if (dbHost != null) {
156+
// LOGGER.info("Saving tenant database host setting");
157+
// Map<String, Object> systemApiRequest = new HashMap<>();
158+
// systemApiRequest.put("resource", "settings/tenant/" + tenantId + "/DB_HOST");
159+
// systemApiRequest.put("method", "PUT");
160+
// systemApiRequest.put("body", "{\"name\":\"DB_HOST\", \"value\":\"" + dbHost + "\"}");
161+
// publishEvent(systemApiRequest, SYSTEM_API_CALL);
162+
// }
163+
// if (albName != null) {
164+
// LOGGER.info("Saving tenant ALB setting");
165+
// Map<String, Object> systemApiRequest = new HashMap<>();
166+
// systemApiRequest.put("resource", "settings/tenant/" + tenantId + "/ALB");
167+
// systemApiRequest.put("method", "PUT");
168+
// systemApiRequest.put("body", "{\"name\":\"ALB\", \"value\":\"" + albName + "\"}");
169+
// publishEvent(systemApiRequest, SYSTEM_API_CALL);
170+
// }
150171
}
151172
return null;
152173
}
@@ -169,4 +190,42 @@ protected static boolean filter(CloudFormationEvent cloudFormationEvent) {
169190
&& STACK_NAME_PATTERN.matcher(cloudFormationEvent.getStackName()).matches()
170191
&& EVENTS_OF_INTEREST.contains(cloudFormationEvent.getResourceStatus()));
171192
}
193+
194+
// LOGGER.info("Stack Outputs:");
195+
// for (Output output : stack.outputs()) {
196+
// LOGGER.info("{} => {}", output.outputKey(), output.outputValue());
197+
// if ("RdsEndpoint".equals(output.outputKey())) {
198+
// if (Utils.isNotBlank(output.outputValue())) {
199+
// dbHost = output.outputValue();
200+
// }
201+
// }
202+
// if ("BillingPlan".equals(output.outputKey())) {
203+
// if (Utils.isNotBlank(output.outputValue())) {
204+
// billingPlan = output.outputValue();
205+
// }
206+
// }
207+
// }
208+
209+
// private void getRdsResources(String stackId, Map<String, String> consoleResources) {
210+
// try {
211+
// ListStackResourcesResponse resources = cfn.listStackResources(request -> request.stackName(stackId));
212+
// for (StackResourceSummary resource : resources.stackResourceSummaries()) {
213+
// String resourceType = resource.resourceType();
214+
// String physicalResourceId = resource.physicalResourceId();
215+
// AwsResource url = null;
216+
// if (resourceType.equalsIgnoreCase(AwsResource.RDS_INSTANCE.getResourceType())) {
217+
// url = AwsResource.RDS_INSTANCE;
218+
// } else if (resourceType.equalsIgnoreCase(AwsResource.RDS_CLUSTER.getResourceType())) {
219+
// url = AwsResource.RDS_CLUSTER;
220+
// }
221+
// if (url != null) {
222+
// consoleResources.put(url.name(), url.formatUrl(AWS_REGION, physicalResourceId));
223+
// }
224+
// }
225+
// } catch (SdkServiceException cfnError) {
226+
// LOGGER.error("cfn:ListStackResources error", cfnError);
227+
// LOGGER.error(Utils.getFullStackTrace(cfnError));
228+
// throw cfnError;
229+
// }
230+
// }
172231
}

functions/onboarding-listener/pom.xml renamed to functions/onboarding-stack-listener/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222
<artifactId>saasboost-functions</artifactId>
2323
<version>1.0.0</version>
2424
</parent>
25-
<artifactId>OnboardingListener</artifactId>
25+
<artifactId>OnboardingStackListener</artifactId>
2626
<version>1.0.0</version>
2727
<packaging>jar</packaging>
2828
<licenses>
@@ -93,6 +93,13 @@ limitations under the License.
9393
<!-- Don't bundle our layer so we get the shared one at runtime -->
9494
<scope>provided</scope>
9595
</dependency>
96+
<dependency>
97+
<groupId>com.amazon.aws.partners.saasfactory.saasboost</groupId>
98+
<artifactId>CloudFormationUtils</artifactId>
99+
<version>1.0.0</version>
100+
<!-- Don't bundle our layer so we get the shared one at runtime -->
101+
<scope>provided</scope>
102+
</dependency>
96103
<dependency>
97104
<groupId>software.amazon.awssdk</groupId>
98105
<artifactId>cloudformation</artifactId>

0 commit comments

Comments
 (0)