Skip to content

Commit

Permalink
feat(clouddriver): Plugin support for clouddriver to override clouddr…
Browse files Browse the repository at this point in the history
…iver code (#140)

* feat(clouddriver): Enable overrides of clouddriver core beans

* feat(clouddriver): Add in some more missing classes to recreate the provider

* chore(lambda): Expose the correct bean to clouddriver

* chore(deps): Fix aws deps

* chore(version): Update release version

* chore(docs): Update version number and docs around this release

* fix(tests): Fixes test compile path

* chore(readme): Update README.md to order the versions better

Co-authored-by: Fernando Freire <[email protected]>

* chore(docs): Update the plugin yaml sample

Co-authored-by: Fernando Freire <[email protected]>

---------

Co-authored-by: Fernando Freire <[email protected]>
  • Loading branch information
jasonmcintosh and dogonthehorizon authored Sep 21, 2023
1 parent f3f8b66 commit 1bf01ee
Show file tree
Hide file tree
Showing 13 changed files with 1,437 additions and 18 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
## Spinnaker Plugin for AWS Lambda Deployment

This plugin provides support for AWS Lambda Deployment via Pipelines in Spinnaker
This plugin provides support for AWS Lambda Deployment via Pipelines in Spinnaker. This repository is in transition
from its current distribution as a plugin into to the core Spinnaker project. Updates will be less frequent until
the migration is complete and feature parity is achieved in future Spinnaker releases.

### Version Compatibility
| Plugin | Spinnaker Platform |
|:------------- | :--------- |
| 1.0.5 <= | 1.23.x |
| 1.0.6 >= | 1.26.x |
| 1.0.11 >= | 1.29.x |
|:------------- |:-------------------|
| 1.0.11 >= | 1.29.x |
| 1.2.0 >= | 1.30.x |
| 1.2.0 <= | 1.32.x |

This plugin is currently only compatible with Spinnaker platform 1.23.x and up. It is possible to run the plugin in an environment running an earlier release by making the following changes to your environment:
1. Checkout `master` branch for `spinnaker/orca`
2. Checkout `master` branch for `spinnaker/deck`
3. Checkout `master` branch for `spinnaker/clouddriver`
4. Install the plugin
This plugin is currently only compatible with Spinnaker platform 1.28.x and up.

## Major changes
11/02/2022 - Release 1.1.0 - removes older versions of the runtime engine from the UI. This means editing older pipelines will no longer let you use the unsupported lambda runtimes. Please see https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html for questions/information.
09/21/2023 - Release 1.2.0 - Adds the ability to override clouddriver native functionality and supports clouddriver plugin. Removed references to unsupported spinnaker versions.

### Requirements
1. This plugin requires Java 11
Expand All @@ -40,12 +39,13 @@ This plugin is currently only compatible with Spinnaker platform 1.23.x and up.
id: awsLambdaDeploymentPluginRepo
url: https://raw.githubusercontent.com/spinnaker-plugins/aws-lambda-deployment-plugin-spinnaker/master/plugins.json

# you can also optionally configure cache refresh retries and timeouts
# you can also optionally configure cache refresh retries and timeouts. Several settings are for
# overall service communication timeouts should be set globally.
# https://github.com/spinnaker/kork/blob/master/kork-web/src/main/groovy/com/netflix/spinnaker/okhttp/OkHttpClientConfigurationProperties.groovy#L29-L32
lambdaPluginConfig:
cloudDriverReadTimeout: 60 # defaults to 60 secs
cloudDriverConnectTimeout: 15 # defaults to 15 secs
cacheRefreshRetryWaitTime: 15 # defaults to 15 sec
cacheOnDemandRetryWaitTime: 15 # defaults to 15 sec
cloudDriverPostRequestRetries: 5 # defaults to 5. Disable if you don't want duplicates.
cloudDriverRetrieveNewPublishedLambdaWaitSeconds: 40 # defaults to 40 sec
cloudDriverRetrieveMaxValidateWeightsTimeSeconds: 240 # defaults to 240 sec
```
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version=1.1.3
version=1.2.0
org.gradle.parallel=true
spinnakerGradleVersion=8.10.0
orcaVersion=8.31.4
clouddriverVersion=5.69.0
clouddriverVersion=5.80.0
org.gradle.jvmarg=-Xmx2048m
6 changes: 6 additions & 0 deletions lambda-deployment-clouddriver/clouddriver-local-sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spinnaker:
extensibility:
plugins:
Aws.LambdaDeploymentPlugin:
enabled: true
version: 1.2.0
72 changes: 72 additions & 0 deletions lambda-deployment-clouddriver/lambda-deployment-clouddriver.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
buildscript {
repositories {
mavenCentral()
}
}

apply plugin: "io.spinnaker.plugin.service-extension"
apply plugin: "maven-publish"
apply plugin: "java"

sourceCompatibility = 11
targetCompatibility = 11

repositories {
mavenCentral()
}

spinnakerPlugin {
serviceName = "clouddriver"
pluginClass = "com.amazon.aws.spinnaker.plugin.lambda.LambdaClouddriverPlugin"
requires="clouddriver>=0.0.0"
}

dependencies {
implementation(enforcedPlatform("io.spinnaker.clouddriver:clouddriver-bom:${clouddriverVersion}"))
compileOnly("com.amazonaws:aws-java-sdk")
compileOnly("com.netflix.awsobjectmapper:awsobjectmapper")
compileOnly("org.apache.commons:commons-lang3")
compileOnly("com.squareup.okhttp3:okhttp")

compileOnly(group: 'org.pf4j', name: 'pf4j')
compileOnly (group: 'io.spinnaker.clouddriver', name: 'clouddriver-api')
compileOnly (group: 'io.spinnaker.clouddriver', name: 'cats-core')
compileOnly(group: 'com.google.guava', name: 'guava')
compileOnly (group: 'io.spinnaker.clouddriver', name: 'clouddriver-lambda')
compileOnly (group: 'io.spinnaker.clouddriver', name: 'clouddriver-security')
compileOnly (group: 'io.spinnaker.clouddriver', name: 'clouddriver-core')
compileOnly (group: 'io.spinnaker.clouddriver', name: 'clouddriver-aws')

compileOnly "com.netflix.spectator:spectator-api"
compileOnly "com.netflix.frigga:frigga"

compileOnly ("org.projectlombok:lombok")
compileOnly (group: 'io.spinnaker.kork', name: 'kork-plugins-spring-api')
compileOnly(group: 'io.spinnaker.kork', name: 'kork-exceptions')

annotationProcessor platform("io.spinnaker.clouddriver:clouddriver-bom:${clouddriverVersion}")
annotationProcessor ("org.projectlombok:lombok")
annotationProcessor("org.pf4j:pf4j")
testAnnotationProcessor platform("io.spinnaker.clouddriver:clouddriver-bom:${clouddriverVersion}")
testAnnotationProcessor ("org.projectlombok:lombok")

testImplementation group: 'io.spinnaker.clouddriver', name: 'clouddriver-api'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api'
testCompile("com.netflix.awsobjectmapper:awsobjectmapper")
testCompile group: 'com.github.tomakehurst', name: 'wiremock-jre8', version: '2.29.1'
testCompile group: 'org.mockito', name: 'mockito-core'
testCompile (group: 'io.spinnaker.clouddriver', name: 'clouddriver-lambda')
testCompile (group: 'io.spinnaker.clouddriver', name: 'clouddriver-aws')
testCompile (group: 'io.spinnaker.clouddriver', name: 'clouddriver-core')
testCompile (group: 'io.spinnaker.clouddriver', name: 'clouddriver-security')
testCompile group: 'org.mockito', name: 'mockito-junit-jupiter'
testCompile group: 'org.projectlombok', name: 'lombok'

testRuntime "org.junit.jupiter:junit-jupiter-engine"
testRuntime "org.junit.platform:junit-platform-launcher"
testRuntime "org.junit.platform:junit-platform-commons"
}

tasks.withType(Test) {
useJUnitPlatform()
}
1 change: 1 addition & 0 deletions lambda-deployment-clouddriver/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.anyConstructor.addConstructorProperties=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.amazon.aws.spinnaker.plugin.lambda;

import com.amazon.aws.spinnaker.plugin.lambda.agent.LambdaAgentProvider;
import com.netflix.spinnaker.kork.plugins.api.spring.SpringLoaderPlugin;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.tuple.Pair;
import org.pf4j.PluginWrapper;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;

import java.util.Arrays;
import java.util.List;

@Log4j2
public class LambdaClouddriverPlugin extends SpringLoaderPlugin {
public LambdaClouddriverPlugin(PluginWrapper wrapper) {
super(wrapper);
}

@Override
public void registerBeanDefinitions(BeanDefinitionRegistry registry) {
List<Pair<String, Class>> beanList = Arrays.asList(
Pair.of("lambdaAgentProvider", LambdaAgentProvider.class)
);
beanList.forEach( curr -> {
BeanDefinition lazyLoadCredentialsRepositoryDefinition = primaryBeanDefinitionFor(curr.getRight());
try {
registry.registerBeanDefinition(curr.getLeft(), lazyLoadCredentialsRepositoryDefinition);
} catch (BeanDefinitionStoreException e) {
log.error("Could not register bean {}", lazyLoadCredentialsRepositoryDefinition.getBeanClassName());
throw new RuntimeException(e);
}
});
super.registerBeanDefinitions(registry);
}

/**
* Specify plugin packages to scan for beans.
*/
public List<String> getPackagesToScan() {
return Arrays.asList("com.amazon.aws.spinnaker.plugin.lambda");
}
}
Loading

0 comments on commit 1bf01ee

Please sign in to comment.