Skip to content

Commit c6b6ba3

Browse files
committed
Rename ecs deploy to workload deploy
1 parent 9efc4ac commit c6b6ba3

File tree

8 files changed

+22
-82
lines changed

8 files changed

+22
-82
lines changed

functions/ecs-deploy/buildspec.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

functions/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<url>https://github.com/awslabs/aws-saas-boost</url>
1616
<modules>
1717
<module>alb-update</module>
18-
<module>ecs-deploy</module>
18+
<module>workload-deploy</module>
1919
<module>ecs-service-update</module>
2020
<module>ecs-shutdown-services</module>
2121
<module>ecs-startup-services</module>

functions/ecs-deploy/pom.xml renamed to functions/workload-deploy/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ limitations under the License.
2323
<version>1.0.0</version>
2424
<relativePath>../</relativePath>
2525
</parent>
26-
<artifactId>EcsDeploy</artifactId>
26+
<artifactId>WorkloadDeploy</artifactId>
2727
<version>1.0.0</version>
2828
<packaging>jar</packaging>
2929
<licenses>
@@ -34,7 +34,7 @@ limitations under the License.
3434
</licenses>
3535

3636
<properties>
37-
<checkstyle.maxAllowedViolations>17</checkstyle.maxAllowedViolations>
37+
<checkstyle.maxAllowedViolations>7</checkstyle.maxAllowedViolations>
3838
</properties>
3939

4040
<build>

functions/ecs-deploy/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/EcsDeploy.java renamed to functions/workload-deploy/src/main/java/com/amazon/aws/partners/saasfactory/saasboost/WorkloadDeploy.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License").
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.amazon.aws.partners.saasfactory.saasboost;
1718

1819
import com.amazonaws.services.lambda.runtime.Context;
@@ -31,26 +32,27 @@
3132

3233
import java.io.ByteArrayOutputStream;
3334
import java.io.IOException;
35+
import java.nio.charset.StandardCharsets;
3436
import java.util.*;
3537
import java.util.stream.Collectors;
3638
import java.util.zip.ZipEntry;
3739
import java.util.zip.ZipOutputStream;
3840

39-
public class EcsDeploy implements RequestHandler<Map<String, Object>, Object> {
41+
public class WorkloadDeploy implements RequestHandler<Map<String, Object>, Object> {
4042

41-
private final static Logger LOGGER = LoggerFactory.getLogger(EcsDeploy.class);
42-
private final static String AWS_REGION = System.getenv("AWS_REGION");
43-
private final static String SAAS_BOOST_ENV = System.getenv("SAAS_BOOST_ENV");
44-
private final static String API_GATEWAY_HOST = System.getenv("API_GATEWAY_HOST");
45-
private final static String API_GATEWAY_STAGE = System.getenv("API_GATEWAY_STAGE");
46-
private final static String API_TRUST_ROLE = System.getenv("API_TRUST_ROLE");
43+
private static final Logger LOGGER = LoggerFactory.getLogger(WorkloadDeploy.class);
44+
private static final String AWS_REGION = System.getenv("AWS_REGION");
45+
private static final String SAAS_BOOST_ENV = System.getenv("SAAS_BOOST_ENV");
46+
private static final String API_GATEWAY_HOST = System.getenv("API_GATEWAY_HOST");
47+
private static final String API_GATEWAY_STAGE = System.getenv("API_GATEWAY_STAGE");
48+
private static final String API_TRUST_ROLE = System.getenv("API_TRUST_ROLE");
4749
private S3Client s3;
4850
private CodePipelineClient codepipeline;
4951
private EcrClient ecr;
5052
private String codePipelineBucket;
5153

52-
public EcsDeploy() {
53-
long startTimeMillis = System.currentTimeMillis();
54+
public WorkloadDeploy() {
55+
final long startTimeMillis = System.currentTimeMillis();
5456
if (Utils.isBlank(AWS_REGION)) {
5557
throw new IllegalStateException("Missing required environment variable AWS_REGION");
5658
}
@@ -104,7 +106,7 @@ public EcsDeploy() {
104106
}
105107

106108
@Override
107-
public Object handleRequest(Map<String, Object> event, Context context) {
109+
public Object handleRequest(Map<String, Object> event, Context context) {
108110
Utils.logRequestEvent(event);
109111

110112
// Is this event an ECR image action or a first-time deploy custom event?
@@ -122,7 +124,7 @@ public Object handleRequest(Map<String, Object> event, Context context) {
122124
SdkHttpFullRequest getTenantsApiRequest = ApiGatewayHelper.getApiRequest(API_GATEWAY_HOST, API_GATEWAY_STAGE, provisionedTenants);
123125
LOGGER.info("Fetching Provisioned tenants from tenants/provisioned");
124126
try {
125-
String functionName = "sb-" + SAAS_BOOST_ENV + "-workload-deploy-" + AWS_REGION;
127+
String functionName = "sb-" + SAAS_BOOST_ENV + "-workload-deploy";
126128
String getTenantsResponseBody = ApiGatewayHelper.signAndExecuteApiRequest(getTenantsApiRequest, API_TRUST_ROLE, functionName);
127129
ArrayList<Map<String, Object>> getTenantsResponse = Utils.fromJson(getTenantsResponseBody, ArrayList.class);
128130
if (null == getTenantsResponse) {
@@ -248,7 +250,7 @@ private byte[] zip(String imagedefinitions) {
248250
ZipOutputStream zip = new ZipOutputStream(stream);
249251
ZipEntry entry = new ZipEntry("imagedefinitions.json");
250252
zip.putNextEntry(entry);
251-
zip.write(imagedefinitions.getBytes());
253+
zip.write(imagedefinitions.getBytes(StandardCharsets.UTF_8));
252254
zip.closeEntry();
253255
zip.close();
254256
archive = stream.toByteArray();
@@ -266,8 +268,8 @@ private void writeToArtifactBucket(String tenantId, byte[] artifact) {
266268
s3.putObject(PutObjectRequest.builder()
267269
.bucket(codePipelineBucket)
268270
.key(key)
269-
.build()
270-
, RequestBody.fromBytes(artifact)
271+
.build(),
272+
RequestBody.fromBytes(artifact)
271273
);
272274
} catch (SdkServiceException s3error) {
273275
LOGGER.error("s3:PutObject " + Utils.getFullStackTrace(s3error));

resources/saas-boost-core.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ Resources:
134134
Runtime: java11
135135
Timeout: 600
136136
MemorySize: 1024
137-
Handler: com.amazon.aws.partners.saasfactory.saasboost.EcsDeploy
137+
Handler: com.amazon.aws.partners.saasfactory.saasboost.WorkloadDeploy
138138
Code:
139139
S3Bucket: !Ref SaaSBoostBucket
140-
S3Key: !Sub ${LambdaSourceFolder}/EcsDeploy-lambda.zip
140+
S3Key: !Sub ${LambdaSourceFolder}/WorkloadDeploy-lambda.zip
141141
Layers:
142142
- !Ref SaaSBoostUtilsLayer
143143
- !Ref ApiGatewayHelperLayer

0 commit comments

Comments
 (0)