fix(aws): add missing atomic operation for lambda publish version
ADD
clouddriver-lambda/src/main/java/com/netflix/spinnaker/clouddriver/lambda/deploy/converters/PublishLambdaFunctionVersionAtomicOperationConverter.java
+/*
+ * Copyright 2018 Amazon.com, Inc. or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.netflix.spinnaker.clouddriver.lambda.deploy.converters;
+
+import com.netflix.spinnaker.clouddriver.lambda.deploy.description.PublishLambdaFunctionVersionDescription;
+import com.netflix.spinnaker.clouddriver.lambda.deploy.ops.PublishLambdaAtomicOperation;
+import com.netflix.spinnaker.clouddriver.orchestration.AtomicOperation;
+import com.netflix.spinnaker.clouddriver.security.AbstractAtomicOperationsCredentialsSupport;
+import java.util.Map;
+import org.springframework.stereotype.Component;
+
+@Component("publishLambdaFunctionVersion")
+public class PublishLambdaFunctionVersionAtomicOperationConverter
+ extends AbstractAtomicOperationsCredentialsSupport {
+
+ @Override
+ public AtomicOperation convertOperation(Map input) {
+ return new PublishLambdaAtomicOperation(convertDescription(input));
+ }
+
+ @Override
+ public PublishLambdaFunctionVersionDescription convertDescription(Map input) {
+ PublishLambdaFunctionVersionDescription converted =
+ getObjectMapper().convertValue(input, PublishLambdaFunctionVersionDescription.class);
+ converted.setCredentials(getCredentialsObject(input.get("credentials").toString()));
+
+ return converted;
+ }
+}

ADD
clouddriver-lambda/src/main/java/com/netflix/spinnaker/clouddriver/lambda/deploy/description/PublishLambdaFunctionVersionDescription.java
+/*
+ * Copyright 2018 Amazon.com, Inc. or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.netflix.spinnaker.clouddriver.lambda.deploy.description;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class PublishLambdaFunctionVersionDescription extends AbstractLambdaFunctionDescription {
+ String functionName;
+ String description;
+ String revisionId;
+}

ADD
clouddriver-lambda/src/main/java/com/netflix/spinnaker/clouddriver/lambda/deploy/ops/PublishLambdaAtomicOperation.java
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.netflix.spinnaker.clouddriver.lambda.deploy.ops;
+
+import com.amazonaws.services.lambda.AWSLambda;
+import com.amazonaws.services.lambda.model.*;
+import com.netflix.spinnaker.clouddriver.lambda.deploy.description.PublishLambdaFunctionVersionDescription;
+import com.netflix.spinnaker.clouddriver.orchestration.AtomicOperation;
+import java.util.List;
+
+public class PublishLambdaAtomicOperation
+ extends AbstractLambdaAtomicOperation<
+ PublishLambdaFunctionVersionDescription, PublishVersionResult>
+ implements AtomicOperation<PublishVersionResult> {
+
+ public PublishLambdaAtomicOperation(PublishLambdaFunctionVersionDescription description) {
+ super(description, "PUBLISH_LAMBDA_FUNCTION_VERSION");
+ }
+
+ @Override
+ public PublishVersionResult operate(List priorOutputs) {
+ updateTaskStatus("Initializing Atomic Operation AWS Lambda for PublishVersion...");
+ return publishFunctionVersion(
+ description.getFunctionName(), description.getDescription(), description.getRevisionId());
+ }
+
+ private PublishVersionResult publishFunctionVersion(
+ String functionName, String description, String revisionId) {
+ AWSLambda client = getLambdaClient();
+ PublishVersionRequest req =
+ new PublishVersionRequest()
+ .withFunctionName(functionName)
+ .withDescription(description)
+ .withRevisionId(revisionId);
+
+ PublishVersionResult result = client.publishVersion(req);
+ updateTaskStatus("Finished Atomic Operation AWS Lambda for PublishVersion...");
+ return result;
+ }
+}

fix(aws): add missing atomic operation for lambda publish version (#4890)

Co-authored-by: smaniyedath <shyam_maniyedath@intuit.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>