Skip to content

Commit 887a527

Browse files
committed
Finishing up RDS bootstrap for multi-container
1 parent bee82b6 commit 887a527

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

resources/custom-resources/rds-bootstrap/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/RdsBootstrap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ private static boolean databaseExists(Connection conn, String engine, String dat
203203
}
204204

205205
public static void createdb(Connection conn, String engine, String database) throws SQLException {
206-
LOGGER.info("Creating {} database", engine);
206+
LOGGER.info("Creating {} database {}", engine, database);
207207
try (Statement create = conn.createStatement()) {
208208
if (engine.contains("postgresql")) {
209209
// Postgres has no real way of doing CREATE DATABASE IF NOT EXISTS...

resources/saas-boost-svc-onboarding.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@ Resources:
560560
PolicyDocument:
561561
Version: 2012-10-17
562562
Statement:
563+
- Effect: Allow
564+
Action:
565+
- logs:CreateLogGroup
566+
- logs:PutRetentionPolicy
567+
Resource:
568+
- !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:*
563569
- Effect: Allow
564570
Action:
565571
- rds:AddTagsToResource

resources/saas-boost-svc-settings.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,13 @@ Resources:
555555
Targets:
556556
- Arn: !GetAtt AppConfigEventHandler.Arn
557557
Id: !Sub sb-${Environment}-settings-app-config-file-event
558+
AppConfigResourceFilesEventPermission:
559+
Type: AWS::Lambda::Permission
560+
Properties:
561+
Action: lambda:InvokeFunction
562+
FunctionName: !Ref AppConfigEventHandler
563+
Principal: events.amazonaws.com
564+
SourceArn: !GetAtt AppConfigResourceFilesEventRule.Arn
558565
Outputs:
559566
SettingsServiceGetAllArn:
560567
Description: Settings Service get all settings Lambda ARN

resources/saas-boost.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ Resources:
854854
Properties:
855855
Name: !Sub /saas-boost/${Environment}/CFN_UTILS_LAYER
856856
Type: String
857-
Value: !Ref SaaSBoostUtilsLayer
857+
Value: !Ref CloudFormationUtilsLayer
858858
Outputs:
859859
SaaSBoostBucket:
860860
Description: S3 bucket with Saas Boost resources

resources/tenant-onboarding-rds.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Resources:
305305
Action:
306306
- s3:GetObject
307307
Resource:
308-
- !Sub arn:aws:s3:::${SaaSBoostBucket}/bootstrap.sql
308+
- !Sub 'arn:aws:s3:::{{resolve:ssm:/saas-boost/${Environment}/RESOURCES_BUCKET}}/services/*'
309309
- Effect: Allow
310310
Action:
311311
- ssm:GetParameter
@@ -352,6 +352,9 @@ Resources:
352352
Layers:
353353
- !Sub '{{resolve:ssm:/saas-boost/${Environment}/UTILS_LAYER}}'
354354
- !Sub '{{resolve:ssm:/saas-boost/${Environment}/CFN_UTILS_LAYER}}'
355+
Environment:
356+
Variables:
357+
SAAS_BOOST_EVENT_BUS: !Sub '{{resolve:ssm:/saas-boost/${Environment}/EVENT_BUS}}'
355358
Tags:
356359
- Key: Tenant
357360
Value: !Ref TenantId
@@ -384,8 +387,8 @@ Resources:
384387
Database: !Ref RDSDatabase
385388
User: !Ref RDSUsername
386389
Password: !Ref RDSPasswordParam # CloudFormation doesn't allow auto decrypting of secure params here...
387-
BootstrapFileBucket: !Ref SaaSBoostBucket
388-
BootstrapFileKey: !If [BootstrapFile, 'bootstrap.sql', '']
390+
BootstrapFileBucket: !Sub '{{resolve:ssm:/saas-boost/${Environment}/RESOURCES_BUCKET}}'
391+
BootstrapFileKey: !Ref RDSBootstrap
389392
Outputs:
390393
RdsEndpoint:
391394
Description: RDS endpoint

services/onboarding-service/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/OnboardingService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,9 +845,10 @@ protected void handleOnboardingBaseProvisioned(Map<String, Object> event, Contex
845845
dbVersion = (String) database.get("version");
846846
dbFamily = (String) database.get("family");
847847
dbInstanceClass = (String) database.get("instanceClass");
848+
dbDatabase = (String) database.get("database");
848849
dbUsername = (String) database.get("username");
849850
dbPort = (Integer) database.get("port");
850-
// TODO fix this dbBootstrap = (String) database.get("DB_BOOTSTRAP_FILE");
851+
dbBootstrap = (String) database.get("bootstrapFilename");
851852
dbPasswordRef = (String) database.get("passwordParam");
852853
}
853854

services/settings-service/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/SettingsService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,9 @@ protected void handleAppConfigResourceChanged(Map<String, Object> event, Context
597597
AppConfig changedAppConfig = Utils.fromJson(json, AppConfig.class);
598598
if (changedAppConfig != null) {
599599
AppConfig existingAppConfig = dal.getAppConfig();
600-
if (AppConfigHelper.isHostedZoneChanged(existingAppConfig, changedAppConfig)) {
600+
// Only updated the hosted zone if it was passed in
601+
if (json.contains("hostedZone")
602+
&& AppConfigHelper.isHostedZoneChanged(existingAppConfig, changedAppConfig)) {
601603
LOGGER.info("Updating hosted zone from {} to {}", existingAppConfig.getHostedZone(),
602604
changedAppConfig.getHostedZone());
603605
// TODO be nice to fix this so you don't have to know the secret path
@@ -607,7 +609,8 @@ protected void handleAppConfigResourceChanged(Map<String, Object> event, Context
607609
.build()
608610
);
609611
}
610-
if (changedAppConfig.getServices() != null) {
612+
// Only update the services if they were passed in
613+
if (json.contains("services") && changedAppConfig.getServices() != null) {
611614
for (Map.Entry<String, ServiceConfig> changedService : changedAppConfig.getServices().entrySet()) {
612615
String changedServiceName = changedService.getKey();
613616
ServiceConfig changedServiceConfig = changedService.getValue();

0 commit comments

Comments
 (0)