@spinnaker/amazon 0.13.9 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/aws.validators.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/stages/deleteLambda/DeleteLambdaFunctionStageForm.d.ts +3 -0
- package/dist/pipeline/stages/deleteLambda/LambdaDeleteStage.d.ts +8 -0
- package/dist/pipeline/stages/deleteLambda/constants/deleteVersion.constants.d.ts +6 -0
- package/dist/pipeline/stages/deleteLambda/constants/deleteVersion.picker.d.ts +16 -0
- package/dist/pipeline/stages/deleteLambda/constants/index.d.ts +2 -0
- package/dist/pipeline/stages/deleteLambda/index.d.ts +1 -0
- package/dist/pipeline/stages/deployLambda/components/AwsLambdaFunctionStageForm.d.ts +3 -0
- package/dist/pipeline/stages/deployLambda/components/BasicSettingsForm.d.ts +3 -0
- package/dist/pipeline/stages/deployLambda/components/EnvironmentForm.d.ts +2 -0
- package/dist/pipeline/stages/deployLambda/components/ExecutionRoleForm.d.ts +2 -0
- package/dist/pipeline/stages/deployLambda/components/LambdaAtEdgeForm.d.ts +3 -0
- package/dist/pipeline/stages/deployLambda/components/NetworkForm.d.ts +3 -0
- package/dist/pipeline/stages/deployLambda/components/TriggerEventsForm.d.ts +3 -0
- package/dist/pipeline/stages/deployLambda/components/function.constants.d.ts +5 -0
- package/dist/pipeline/stages/deployLambda/components/index.d.ts +5 -0
- package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStage.d.ts +3 -0
- package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStageConfig.d.ts +4 -0
- package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStageExecutionDetails.d.ts +6 -0
- package/dist/pipeline/stages/deployLambda/config/UpsertDefaults.d.ts +1 -0
- package/dist/pipeline/stages/deployLambda/config/function.defaults.d.ts +2 -0
- package/dist/pipeline/stages/deployLambda/index.d.ts +1 -0
- package/dist/pipeline/stages/invokeLambda/InvokeLambdaFunctionStageForm.d.ts +3 -0
- package/dist/pipeline/stages/invokeLambda/LambdaInvokeStage.d.ts +8 -0
- package/dist/pipeline/stages/invokeLambda/components/InvokeLambdaOperation.d.ts +3 -0
- package/dist/pipeline/stages/invokeLambda/components/index.d.ts +1 -0
- package/dist/pipeline/stages/invokeLambda/index.d.ts +1 -0
- package/dist/pipeline/stages/routeLambda/LambdaRouteStage.d.ts +8 -0
- package/dist/pipeline/stages/routeLambda/RouteLambdaFunctionStageForm.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/TriggerEventsForm.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/BlueGreenDeploymentForm.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/HealthCheckStrategy.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/InvocationHealthCheck.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/health.constants.d.ts +5 -0
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/index.d.ts +1 -0
- package/dist/pipeline/stages/routeLambda/components/DeploymentStrategyForm.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/RenderStrategy.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/SimpleDeploymentForm.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/VersionPicker.d.ts +14 -0
- package/dist/pipeline/stages/routeLambda/components/WeightedDeploymentForm.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/components/index.d.ts +1 -0
- package/dist/pipeline/stages/routeLambda/constants/index.d.ts +3 -0
- package/dist/pipeline/stages/routeLambda/constants/strategy.constants.d.ts +6 -0
- package/dist/pipeline/stages/routeLambda/constants/strategy.picker.d.ts +16 -0
- package/dist/pipeline/stages/routeLambda/constants/versions.constants.d.ts +6 -0
- package/dist/pipeline/stages/routeLambda/index.d.ts +1 -0
- package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStage.d.ts +3 -0
- package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageConfig.d.ts +5 -0
- package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageExecutionDetails.d.ts +6 -0
- package/dist/pipeline/stages/updateCodeLambda/components/UpdateCodeStageForm.d.ts +3 -0
- package/dist/pipeline/stages/updateCodeLambda/components/index.d.ts +1 -0
- package/dist/pipeline/stages/updateCodeLambda/index.d.ts +1 -0
- package/package.json +3 -3
- package/src/aws.module.ts +6 -6
- package/src/aws.validators.ts +7 -3
- package/src/pipeline/stages/deleteLambda/DeleteLambdaFunctionStageForm.tsx +143 -0
- package/src/pipeline/stages/deleteLambda/LambdaDeleteStage.tsx +86 -0
- package/src/pipeline/stages/deleteLambda/constants/deleteVersion.constants.ts +37 -0
- package/src/pipeline/stages/deleteLambda/constants/deleteVersion.picker.tsx +47 -0
- package/src/pipeline/stages/deleteLambda/constants/index.ts +5 -0
- package/src/pipeline/stages/deleteLambda/index.ts +11 -0
- package/src/pipeline/stages/deployLambda/components/AwsLambdaFunctionStageForm.tsx +139 -0
- package/src/pipeline/stages/deployLambda/components/BasicSettingsForm.tsx +176 -0
- package/src/pipeline/stages/deployLambda/components/EnvironmentForm.tsx +24 -0
- package/src/pipeline/stages/deployLambda/components/ExecutionRoleForm.tsx +15 -0
- package/src/pipeline/stages/deployLambda/components/LambdaAtEdgeForm.tsx +28 -0
- package/src/pipeline/stages/deployLambda/components/NetworkForm.tsx +123 -0
- package/src/pipeline/stages/deployLambda/components/TriggerEventsForm.tsx +49 -0
- package/src/pipeline/stages/deployLambda/components/function.constants.ts +32 -0
- package/src/pipeline/stages/deployLambda/components/index.ts +8 -0
- package/src/pipeline/stages/deployLambda/config/LambdaDeploymentStage.tsx +20 -0
- package/src/pipeline/stages/deployLambda/config/LambdaDeploymentStageConfig.tsx +64 -0
- package/src/pipeline/stages/deployLambda/config/LambdaDeploymentStageExecutionDetails.tsx +31 -0
- package/src/pipeline/stages/deployLambda/config/UpsertDefaults.tsx +21 -0
- package/src/pipeline/stages/deployLambda/config/function.defaults.ts +39 -0
- package/src/pipeline/stages/deployLambda/index.ts +11 -0
- package/src/pipeline/stages/invokeLambda/InvokeLambdaFunctionStageForm.tsx +106 -0
- package/src/pipeline/stages/invokeLambda/LambdaInvokeStage.tsx +125 -0
- package/src/pipeline/stages/invokeLambda/components/InvokeLambdaOperation.tsx +77 -0
- package/src/pipeline/stages/invokeLambda/components/index.ts +4 -0
- package/src/pipeline/stages/invokeLambda/index.ts +11 -0
- package/src/pipeline/stages/routeLambda/LambdaRouteStage.tsx +98 -0
- package/src/pipeline/stages/routeLambda/RouteLambdaFunctionStageForm.tsx +151 -0
- package/src/pipeline/stages/routeLambda/TriggerEventsForm.tsx +51 -0
- package/src/pipeline/stages/routeLambda/components/BlueGreenDeployment/BlueGreenDeploymentForm.tsx +27 -0
- package/src/pipeline/stages/routeLambda/components/BlueGreenDeployment/HealthCheckStrategy.tsx +21 -0
- package/src/pipeline/stages/routeLambda/components/BlueGreenDeployment/InvocationHealthCheck.tsx +93 -0
- package/src/pipeline/stages/routeLambda/components/BlueGreenDeployment/health.constants.ts +14 -0
- package/src/pipeline/stages/routeLambda/components/BlueGreenDeployment/index.ts +4 -0
- package/src/pipeline/stages/routeLambda/components/DeploymentStrategyForm.tsx +18 -0
- package/src/pipeline/stages/routeLambda/components/RenderStrategy.tsx +23 -0
- package/src/pipeline/stages/routeLambda/components/SimpleDeploymentForm.tsx +67 -0
- package/src/pipeline/stages/routeLambda/components/VersionPicker.tsx +43 -0
- package/src/pipeline/stages/routeLambda/components/WeightedDeploymentForm.tsx +107 -0
- package/src/pipeline/stages/routeLambda/components/index.ts +4 -0
- package/src/pipeline/stages/routeLambda/constants/index.ts +6 -0
- package/src/pipeline/stages/routeLambda/constants/strategy.constants.tsx +26 -0
- package/src/pipeline/stages/routeLambda/constants/strategy.picker.tsx +47 -0
- package/src/pipeline/stages/routeLambda/constants/versions.constants.ts +31 -0
- package/src/pipeline/stages/routeLambda/index.ts +11 -0
- package/src/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStage.tsx +20 -0
- package/src/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageConfig.tsx +41 -0
- package/src/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageExecutionDetails.tsx +31 -0
- package/src/pipeline/stages/updateCodeLambda/components/UpdateCodeStageForm.tsx +122 -0
- package/src/pipeline/stages/updateCodeLambda/components/index.ts +4 -0
- package/src/pipeline/stages/updateCodeLambda/index.ts +11 -0
- package/src/serverGroup/details/scalingPolicy/upsert/step/StepPolicyAction.tsx +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
|
|
4
|
+
export const availableRuntimes = [
|
|
5
|
+
'nodejs12.x',
|
|
6
|
+
'nodejs14.x',
|
|
7
|
+
'nodejs16.x',
|
|
8
|
+
'nodejs18.x',
|
|
9
|
+
'java8',
|
|
10
|
+
'java8.al2',
|
|
11
|
+
'java11',
|
|
12
|
+
'java17',
|
|
13
|
+
'python3.7',
|
|
14
|
+
'python3.8',
|
|
15
|
+
'python3.9',
|
|
16
|
+
'python3.10',
|
|
17
|
+
'dotnetcore3.1',
|
|
18
|
+
'dotnet7',
|
|
19
|
+
'dotnet6',
|
|
20
|
+
'dotnet5.0',
|
|
21
|
+
'go1.x',
|
|
22
|
+
'ruby2.7',
|
|
23
|
+
'provided',
|
|
24
|
+
'provided.al2',
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export const lambdaHelpFields = {
|
|
28
|
+
stack:
|
|
29
|
+
'(Optional) Stack is naming components of a function, used to create vertical stacks of dependent services for integration testing.',
|
|
30
|
+
detail:
|
|
31
|
+
'(Optional) Detail is a string of free-form alphanumeric characters to describe any other variables in naming a function.',
|
|
32
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export * from './BasicSettingsForm';
|
|
5
|
+
export * from './NetworkForm';
|
|
6
|
+
export * from './ExecutionRoleForm';
|
|
7
|
+
export * from './TriggerEventsForm';
|
|
8
|
+
export * from './LambdaAtEdgeForm';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import type { IStageTypeConfig } from '@spinnaker/core';
|
|
4
|
+
import { ExecutionDetailsTasks, HelpContentsRegistry } from '@spinnaker/core';
|
|
5
|
+
|
|
6
|
+
import { LambdaDeploymentConfig, validate } from './LambdaDeploymentStageConfig';
|
|
7
|
+
import { LambdaDeploymentExecutionDetails } from './LambdaDeploymentStageExecutionDetails';
|
|
8
|
+
|
|
9
|
+
export const initialize = () => {
|
|
10
|
+
HelpContentsRegistry.register('aws.lambdaDeploymentStage.lambda', 'Lambda Name');
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const lambdaDeploymentStage: IStageTypeConfig = {
|
|
14
|
+
key: 'Aws.LambdaDeploymentStage',
|
|
15
|
+
label: `AWS Lambda Deployment`,
|
|
16
|
+
description: 'Create a Single AWS Lambda Function',
|
|
17
|
+
component: LambdaDeploymentConfig, // stage config
|
|
18
|
+
executionDetailsSections: [LambdaDeploymentExecutionDetails, ExecutionDetailsTasks],
|
|
19
|
+
validateFn: validate,
|
|
20
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import type { IFormikStageConfigInjectedProps, IStage, IStageConfigProps } from '@spinnaker/core';
|
|
6
|
+
import { FormikStageConfig, FormValidator } from '@spinnaker/core';
|
|
7
|
+
|
|
8
|
+
import { upsertDefaults } from './UpsertDefaults';
|
|
9
|
+
import {
|
|
10
|
+
awsArnValidator,
|
|
11
|
+
iamRoleValidator,
|
|
12
|
+
s3BucketNameValidator,
|
|
13
|
+
simpleStringValidator,
|
|
14
|
+
} from '../../../../aws.validators';
|
|
15
|
+
import { AwsLambdaFunctionStageForm } from '../components/AwsLambdaFunctionStageForm';
|
|
16
|
+
import { constructNewAwsFunctionTemplate } from './function.defaults';
|
|
17
|
+
|
|
18
|
+
export function LambdaDeploymentConfig(props: IStageConfigProps) {
|
|
19
|
+
const defaultFunction = constructNewAwsFunctionTemplate();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="LambdaDeploymentConfig">
|
|
23
|
+
<FormikStageConfig
|
|
24
|
+
{...props}
|
|
25
|
+
stage={upsertDefaults(props.stage, defaultFunction)}
|
|
26
|
+
validate={validate}
|
|
27
|
+
onChange={props.updateStage}
|
|
28
|
+
render={(props: IFormikStageConfigInjectedProps) => <AwsLambdaFunctionStageForm {...props} />}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function validate(stageConfig: IStage) {
|
|
35
|
+
const validator = new FormValidator(stageConfig);
|
|
36
|
+
|
|
37
|
+
validator.field('runtime', 'Runtime').required();
|
|
38
|
+
validator.field('s3key', 'S3 Object Key').required();
|
|
39
|
+
validator.field('handler', 'Handler').required();
|
|
40
|
+
validator.field('functionUid', 'Function Name').required();
|
|
41
|
+
|
|
42
|
+
validator.field('stackName', 'Stack Name').optional().withValidators(simpleStringValidator);
|
|
43
|
+
|
|
44
|
+
validator.field('detailName', 'Detail Name').optional().withValidators(simpleStringValidator);
|
|
45
|
+
|
|
46
|
+
validator.field('s3bucket', 'S3 Bucket Name').required().withValidators(s3BucketNameValidator);
|
|
47
|
+
|
|
48
|
+
validator.field('role', 'Role ARN').required().withValidators(iamRoleValidator);
|
|
49
|
+
|
|
50
|
+
validator
|
|
51
|
+
.field('triggerArns', 'Trigger ARNs')
|
|
52
|
+
.optional()
|
|
53
|
+
.withValidators((value: any, _: string) => {
|
|
54
|
+
const tmp: any[] = value.map((arn: string) => {
|
|
55
|
+
return awsArnValidator(arn, arn);
|
|
56
|
+
});
|
|
57
|
+
const ret: boolean = tmp.every((el) => el === undefined);
|
|
58
|
+
return ret
|
|
59
|
+
? undefined
|
|
60
|
+
: 'Invalid ARN. Event ARN must match regular expression: /^arn:aws[a-zA-Z-]?:[a-zA-Z_0-9.-]+:./';
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return validator.validateForm();
|
|
64
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type { IExecutionDetailsSectionProps } from '@spinnaker/core';
|
|
7
|
+
import { ExecutionDetailsSection, StageFailureMessage } from '@spinnaker/core';
|
|
8
|
+
|
|
9
|
+
export function LambdaDeploymentExecutionDetails(props: IExecutionDetailsSectionProps) {
|
|
10
|
+
const { stage, current, name } = props;
|
|
11
|
+
return (
|
|
12
|
+
<ExecutionDetailsSection name={name} current={current}>
|
|
13
|
+
<StageFailureMessage stage={stage} message={stage.outputs.failureMessage} />
|
|
14
|
+
<div>
|
|
15
|
+
<p>
|
|
16
|
+
{' '}
|
|
17
|
+
<b> Function Name: </b> {stage.outputs.functionName ? stage.outputs.functionName : 'N/A'}{' '}
|
|
18
|
+
</p>
|
|
19
|
+
<p>
|
|
20
|
+
{' '}
|
|
21
|
+
<b> Function ARN: </b> {stage.outputs.functionARN ? stage.outputs.functionARN : 'N/A'}{' '}
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
24
|
+
</ExecutionDetailsSection>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line
|
|
29
|
+
export namespace LambdaDeploymentExecutionDetails {
|
|
30
|
+
export const title = 'Lambda Deployment Stage';
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { isNil, isString } from 'lodash';
|
|
4
|
+
|
|
5
|
+
function isEmptyString(val: any) {
|
|
6
|
+
if (isString(val)) {
|
|
7
|
+
if (isNil(val) || val === '') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function upsertDefaults(initialValues: any, defaultValues: any) {
|
|
15
|
+
Object.entries(defaultValues).forEach(([key, value]) => {
|
|
16
|
+
if (!initialValues[key] && !isEmptyString(value)) {
|
|
17
|
+
initialValues[key] = value;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return initialValues;
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import type { IAmazonFunctionUpsertCommand } from '../../../../domain';
|
|
4
|
+
|
|
5
|
+
export function constructNewAwsFunctionTemplate(): IAmazonFunctionUpsertCommand {
|
|
6
|
+
const defaultCredentials = '';
|
|
7
|
+
const defaultRegion = '';
|
|
8
|
+
return {
|
|
9
|
+
role: '',
|
|
10
|
+
runtime: '',
|
|
11
|
+
s3key: '',
|
|
12
|
+
s3bucket: '',
|
|
13
|
+
handler: '',
|
|
14
|
+
functionName: '',
|
|
15
|
+
publish: false,
|
|
16
|
+
tags: {},
|
|
17
|
+
memorySize: 128,
|
|
18
|
+
description: '',
|
|
19
|
+
|
|
20
|
+
credentials: defaultCredentials,
|
|
21
|
+
cloudProvider: 'aws',
|
|
22
|
+
region: defaultRegion,
|
|
23
|
+
envVariables: {},
|
|
24
|
+
|
|
25
|
+
tracingConfig: {
|
|
26
|
+
mode: 'PassThrough',
|
|
27
|
+
},
|
|
28
|
+
kmskeyArn: '',
|
|
29
|
+
vpcId: '',
|
|
30
|
+
subnetIds: [],
|
|
31
|
+
securityGroupIds: [],
|
|
32
|
+
timeout: 3,
|
|
33
|
+
deadLetterConfig: {
|
|
34
|
+
targetArn: '',
|
|
35
|
+
},
|
|
36
|
+
operation: '',
|
|
37
|
+
targetGroups: '',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { Registry, SETTINGS } from '@spinnaker/core';
|
|
5
|
+
import { lambdaDeploymentStage } from './config/LambdaDeploymentStage';
|
|
6
|
+
|
|
7
|
+
export * from './config/LambdaDeploymentStage';
|
|
8
|
+
|
|
9
|
+
if (SETTINGS.feature.lambdaAdditionalStages) {
|
|
10
|
+
Registry.pipeline.registerStage(lambdaDeploymentStage);
|
|
11
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
IAccount,
|
|
7
|
+
IAccountDetails,
|
|
8
|
+
IFormikStageConfigInjectedProps,
|
|
9
|
+
IFormInputProps,
|
|
10
|
+
IFunction,
|
|
11
|
+
IRegion,
|
|
12
|
+
} from '@spinnaker/core';
|
|
13
|
+
import { AccountService, FormikFormField, ReactSelectInput, TextInput, useData } from '@spinnaker/core';
|
|
14
|
+
|
|
15
|
+
import { InvokeLambdaOperation } from './components';
|
|
16
|
+
|
|
17
|
+
export function InvokeLambdaFunctionStageForm(props: IFormikStageConfigInjectedProps) {
|
|
18
|
+
const { values } = props.formik;
|
|
19
|
+
const { functions } = props.application;
|
|
20
|
+
|
|
21
|
+
const { result: fetchAccountsResult, status: fetchAccountsStatus } = useData(
|
|
22
|
+
() => AccountService.listAccounts('aws'),
|
|
23
|
+
[],
|
|
24
|
+
[],
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const onAccountChange = (fieldValue: any): void => {
|
|
28
|
+
props.formik.setFieldValue('region', null);
|
|
29
|
+
props.formik.setFieldValue('functionName', null);
|
|
30
|
+
|
|
31
|
+
props.formik.setFieldValue('account', fieldValue);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const onRegionChange = (fieldValue: any): void => {
|
|
35
|
+
props.formik.setFieldValue('functionName', null);
|
|
36
|
+
props.formik.setFieldValue('region', fieldValue);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const availableFunctions =
|
|
40
|
+
values.account && values.region
|
|
41
|
+
? functions.data
|
|
42
|
+
.filter((f: IFunction) => f.account === values.account)
|
|
43
|
+
.filter((f: IFunction) => f.region === values.region)
|
|
44
|
+
.map((f: IFunction) => f.functionName)
|
|
45
|
+
: [];
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="form-horizontal">
|
|
49
|
+
<h4> Basic Settings </h4>
|
|
50
|
+
<FormikFormField
|
|
51
|
+
label="Account"
|
|
52
|
+
name="account"
|
|
53
|
+
onChange={onAccountChange}
|
|
54
|
+
required={true}
|
|
55
|
+
input={(inputProps: IFormInputProps) => (
|
|
56
|
+
<ReactSelectInput
|
|
57
|
+
{...inputProps}
|
|
58
|
+
clearable={false}
|
|
59
|
+
isLoading={fetchAccountsStatus === 'PENDING'}
|
|
60
|
+
stringOptions={fetchAccountsResult.map((acc: IAccount) => acc.name)}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
/>
|
|
64
|
+
<FormikFormField
|
|
65
|
+
label="Region"
|
|
66
|
+
name="region"
|
|
67
|
+
onChange={onRegionChange}
|
|
68
|
+
input={(inputProps: IFormInputProps) => (
|
|
69
|
+
<ReactSelectInput
|
|
70
|
+
clearable={false}
|
|
71
|
+
disabled={!values.account}
|
|
72
|
+
placeholder={values.account ? 'Select...' : 'Select an Account...'}
|
|
73
|
+
{...inputProps}
|
|
74
|
+
isLoading={fetchAccountsStatus === 'PENDING'}
|
|
75
|
+
stringOptions={fetchAccountsResult
|
|
76
|
+
.filter((acc: IAccountDetails) => acc.name === values.account)
|
|
77
|
+
.flatMap((acc: IAccountDetails) => acc.regions)
|
|
78
|
+
.map((reg: IRegion) => reg.name)}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
/>
|
|
82
|
+
<FormikFormField
|
|
83
|
+
label="Function Name"
|
|
84
|
+
name="functionName"
|
|
85
|
+
input={(inputProps: IFormInputProps) => (
|
|
86
|
+
<ReactSelectInput
|
|
87
|
+
clearable={false}
|
|
88
|
+
disabled={!(values.account && values.region)}
|
|
89
|
+
placeholder={values.account && values.region ? 'Select...' : 'Select an Account and Region...'}
|
|
90
|
+
{...inputProps}
|
|
91
|
+
stringOptions={availableFunctions}
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
/>
|
|
95
|
+
|
|
96
|
+
<FormikFormField
|
|
97
|
+
label="Alias"
|
|
98
|
+
name="aliasName"
|
|
99
|
+
input={(inputProps: IFormInputProps) => <TextInput {...inputProps} />}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<h4> Invoke Settings </h4>
|
|
103
|
+
<InvokeLambdaOperation {...props} />
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IExecutionDetailsSectionProps,
|
|
8
|
+
IFormikStageConfigInjectedProps,
|
|
9
|
+
IStage,
|
|
10
|
+
IStageConfigProps,
|
|
11
|
+
IStageTypeConfig,
|
|
12
|
+
} from '@spinnaker/core';
|
|
13
|
+
import {
|
|
14
|
+
ExecutionDetailsSection,
|
|
15
|
+
ExecutionDetailsTasks,
|
|
16
|
+
FormikStageConfig,
|
|
17
|
+
FormValidator,
|
|
18
|
+
HelpContentsRegistry,
|
|
19
|
+
StageFailureMessage,
|
|
20
|
+
} from '@spinnaker/core';
|
|
21
|
+
|
|
22
|
+
import { InvokeLambdaFunctionStageForm } from './InvokeLambdaFunctionStageForm';
|
|
23
|
+
import { awsArnValidator } from '../../../aws.validators';
|
|
24
|
+
|
|
25
|
+
export function InvokeLambdaExecutionDetails(props: IExecutionDetailsSectionProps) {
|
|
26
|
+
const { stage } = props;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ExecutionDetailsSection name={props.name} current={props.current}>
|
|
30
|
+
<StageFailureMessage stage={stage} message={stage.outputs.failureMessage} />
|
|
31
|
+
<div>
|
|
32
|
+
<p> Function Name: {stage.outputs.functionName ? stage.outputs.functionName : 'N/A'} </p>
|
|
33
|
+
<p>
|
|
34
|
+
{' '}
|
|
35
|
+
Deployed Alias:{' '}
|
|
36
|
+
{stage.outputs['deployment:aliasDeployed'] ? stage.outputs['deployment:aliasDeployed'] : 'N/A'}{' '}
|
|
37
|
+
</p>
|
|
38
|
+
<p>
|
|
39
|
+
{' '}
|
|
40
|
+
Deployed Major Version:{' '}
|
|
41
|
+
{stage.outputs['deployment:majorVersionDeployed']
|
|
42
|
+
? stage.outputs['deployment:majorVersionDeployed']
|
|
43
|
+
: 'N/A'}{' '}
|
|
44
|
+
</p>
|
|
45
|
+
</div>
|
|
46
|
+
</ExecutionDetailsSection>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
IStageConfigProps defines properties passed to all Spinnaker Stages.
|
|
52
|
+
See IStageConfigProps.ts (https://github.com/spinnaker/deck/blob/master/app/scripts/modules/core/src/pipeline/config/stages/common/IStageConfigProps.ts) for a complete list of properties.
|
|
53
|
+
Pass a JSON object to the `updateStageField` method to add the `account` to the Stage.
|
|
54
|
+
|
|
55
|
+
This method returns JSX (https://reactjs.org/docs/introducing-jsx.html) that gets displayed in the Spinnaker UI.
|
|
56
|
+
*/
|
|
57
|
+
function InvokeLambdaConfig(props: IStageConfigProps) {
|
|
58
|
+
return (
|
|
59
|
+
<div className="InvokeLambdaStageConfig">
|
|
60
|
+
<FormikStageConfig
|
|
61
|
+
{...props}
|
|
62
|
+
validate={validate}
|
|
63
|
+
onChange={props.updateStage}
|
|
64
|
+
render={(props: IFormikStageConfigInjectedProps) => <InvokeLambdaFunctionStageForm {...props} />}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
This is a contrived example of how to use an `initialize` function to hook into arbitrary Deck services.
|
|
72
|
+
This `initialize` function provides the help field text for the `LambdaDeploymentConfig` stage form defined above.
|
|
73
|
+
|
|
74
|
+
You can hook into any service exported by the `@spinnaker/core` NPM module, e.g.:
|
|
75
|
+
- CloudProviderRegistry
|
|
76
|
+
- DeploymentStrategyRegistry
|
|
77
|
+
|
|
78
|
+
When you use a registry, you are diving into Deck's implementation to add functionality.
|
|
79
|
+
These registries and their methods may change without warning.
|
|
80
|
+
*/
|
|
81
|
+
export const initialize = () => {
|
|
82
|
+
HelpContentsRegistry.register('aws.lambdaDeploymentStage.lambda', 'Lambda Name');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function validate(stageConfig: IStage) {
|
|
86
|
+
const validator = new FormValidator(stageConfig);
|
|
87
|
+
|
|
88
|
+
validator
|
|
89
|
+
.field('triggerArns', 'Trigger ARNs')
|
|
90
|
+
.optional()
|
|
91
|
+
.withValidators((value: any, _: string) => {
|
|
92
|
+
const tmp: any[] = value.map((arn: string) => {
|
|
93
|
+
return awsArnValidator(arn, arn);
|
|
94
|
+
});
|
|
95
|
+
const ret: boolean = tmp.every((el) => el === undefined);
|
|
96
|
+
return ret
|
|
97
|
+
? undefined
|
|
98
|
+
: 'Invalid ARN. Event ARN must match regular expression: /^arn:aws[a-zA-Z-]?:[a-zA-Z_0-9.-]+:./';
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return validator.validateForm();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// eslint-disable-next-line
|
|
105
|
+
export namespace InvokeLambdaExecutionDetails {
|
|
106
|
+
export const title = 'Invoke Lambda Stage';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
Define Spinnaker Stages with IStageTypeConfig.
|
|
111
|
+
Required options: https://github.com/spinnaker/deck/master/app/scripts/modules/core/src/domain/IStageTypeConfig.ts
|
|
112
|
+
- label -> The name of the Stage
|
|
113
|
+
- description -> Long form that describes what the Stage actually does
|
|
114
|
+
- key -> A unique name for the Stage in the UI; ties to Orca backend
|
|
115
|
+
- component -> The rendered React component
|
|
116
|
+
- validateFn -> A validation function for the stage config form.
|
|
117
|
+
*/
|
|
118
|
+
export const lambdaInvokeStage: IStageTypeConfig = {
|
|
119
|
+
key: 'Aws.LambdaInvokeStage',
|
|
120
|
+
label: `AWS Lambda Invoke`,
|
|
121
|
+
description: 'Invoke a Lambda function',
|
|
122
|
+
component: InvokeLambdaConfig, // stage config
|
|
123
|
+
executionDetailsSections: [InvokeLambdaExecutionDetails, ExecutionDetailsTasks],
|
|
124
|
+
validateFn: validate,
|
|
125
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type { IArtifact, IExpectedArtifact, IFormikStageConfigInjectedProps } from '@spinnaker/core';
|
|
7
|
+
import {
|
|
8
|
+
ArtifactTypePatterns,
|
|
9
|
+
excludeAllTypesExcept,
|
|
10
|
+
FormikFormField,
|
|
11
|
+
NumberInput,
|
|
12
|
+
StageArtifactSelectorDelegate,
|
|
13
|
+
} from '@spinnaker/core';
|
|
14
|
+
|
|
15
|
+
export function InvokeLambdaOperation(props: IFormikStageConfigInjectedProps) {
|
|
16
|
+
const { values } = props.formik;
|
|
17
|
+
|
|
18
|
+
const excludedArtifactTypes = excludeAllTypesExcept(
|
|
19
|
+
ArtifactTypePatterns.BITBUCKET_FILE,
|
|
20
|
+
ArtifactTypePatterns.CUSTOM_OBJECT,
|
|
21
|
+
ArtifactTypePatterns.EMBEDDED_BASE64,
|
|
22
|
+
ArtifactTypePatterns.GCS_OBJECT,
|
|
23
|
+
ArtifactTypePatterns.GITHUB_FILE,
|
|
24
|
+
ArtifactTypePatterns.GITLAB_FILE,
|
|
25
|
+
ArtifactTypePatterns.S3_OBJECT,
|
|
26
|
+
ArtifactTypePatterns.HTTP_FILE,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const onTemplateArtifactEdited = (artifact: IArtifact, name: string) => {
|
|
30
|
+
props.formik.setFieldValue(`${name}.id`, null);
|
|
31
|
+
props.formik.setFieldValue(`${name}.artifact`, artifact);
|
|
32
|
+
props.formik.setFieldValue(`${name}.account`, artifact.artifactAccount);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const onTemplateArtifactSelected = (id: string, name: string) => {
|
|
36
|
+
props.formik.setFieldValue(`${name}.id`, id);
|
|
37
|
+
props.formik.setFieldValue(`${name}.artifact`, null);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getInputArtifact = (stage: any, name: string) => {
|
|
41
|
+
if (!stage[name]) {
|
|
42
|
+
return {
|
|
43
|
+
account: '',
|
|
44
|
+
id: '',
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
return stage[name];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div>
|
|
53
|
+
<FormikFormField name="timeout" label="Timeout" input={(props) => <NumberInput {...props} min={0} max={900} />} />
|
|
54
|
+
<FormikFormField
|
|
55
|
+
name="executionCount"
|
|
56
|
+
label="Execution Count"
|
|
57
|
+
input={(props) => <NumberInput {...props} min={0} max={100} />}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<StageArtifactSelectorDelegate
|
|
61
|
+
artifact={getInputArtifact(values, 'payloadArtifact').artifact}
|
|
62
|
+
excludedArtifactTypePatterns={excludedArtifactTypes}
|
|
63
|
+
expectedArtifactId={getInputArtifact(values, 'payloadArtifact').id}
|
|
64
|
+
label="Payload Artifact"
|
|
65
|
+
onArtifactEdited={(artifact: any) => {
|
|
66
|
+
onTemplateArtifactEdited(artifact, 'payloadArtifact');
|
|
67
|
+
}}
|
|
68
|
+
helpKey={''}
|
|
69
|
+
onExpectedArtifactSelected={(artifact: IExpectedArtifact) =>
|
|
70
|
+
onTemplateArtifactSelected(artifact.id, 'payloadrtifact')
|
|
71
|
+
}
|
|
72
|
+
pipeline={props.pipeline}
|
|
73
|
+
stage={values}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { Registry, SETTINGS } from '@spinnaker/core';
|
|
5
|
+
import { lambdaInvokeStage } from './LambdaInvokeStage';
|
|
6
|
+
|
|
7
|
+
export * from './LambdaInvokeStage';
|
|
8
|
+
|
|
9
|
+
if (SETTINGS.feature.lambdaAdditionalStages) {
|
|
10
|
+
Registry.pipeline.registerStage(lambdaInvokeStage);
|
|
11
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IExecutionDetailsSectionProps,
|
|
8
|
+
IFormikStageConfigInjectedProps,
|
|
9
|
+
IStage,
|
|
10
|
+
IStageConfigProps,
|
|
11
|
+
IStageTypeConfig,
|
|
12
|
+
} from '@spinnaker/core';
|
|
13
|
+
import {
|
|
14
|
+
ExecutionDetailsSection,
|
|
15
|
+
ExecutionDetailsTasks,
|
|
16
|
+
FormikStageConfig,
|
|
17
|
+
FormValidator,
|
|
18
|
+
HelpContentsRegistry,
|
|
19
|
+
StageFailureMessage,
|
|
20
|
+
} from '@spinnaker/core';
|
|
21
|
+
|
|
22
|
+
import { RouteLambdaFunctionStageForm } from './RouteLambdaFunctionStageForm';
|
|
23
|
+
import { awsArnValidator } from '../../../aws.validators';
|
|
24
|
+
|
|
25
|
+
export function RouteLambdaExecutionDetails(props: IExecutionDetailsSectionProps) {
|
|
26
|
+
const { stage } = props;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ExecutionDetailsSection name={props.name} current={props.current}>
|
|
30
|
+
<StageFailureMessage stage={stage} message={stage.outputs.failureMessage} />
|
|
31
|
+
<div>
|
|
32
|
+
<p> Function Name: {stage.outputs.functionName ? stage.outputs.functionName : 'N/A'} </p>
|
|
33
|
+
<p>
|
|
34
|
+
{' '}
|
|
35
|
+
Deployed Alias:{' '}
|
|
36
|
+
{stage.outputs['deployment:aliasDeployed'] ? stage.outputs['deployment:aliasDeployed'] : 'N/A'}{' '}
|
|
37
|
+
</p>
|
|
38
|
+
<p>
|
|
39
|
+
{' '}
|
|
40
|
+
Deployed Major Version:{' '}
|
|
41
|
+
{stage.outputs['deployment:majorVersionDeployed']
|
|
42
|
+
? stage.outputs['deployment:majorVersionDeployed']
|
|
43
|
+
: 'N/A'}{' '}
|
|
44
|
+
</p>
|
|
45
|
+
</div>
|
|
46
|
+
</ExecutionDetailsSection>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function RouteLambdaConfig(props: IStageConfigProps) {
|
|
51
|
+
return (
|
|
52
|
+
<div className="RouteLambdaStageConfig">
|
|
53
|
+
<FormikStageConfig
|
|
54
|
+
{...props}
|
|
55
|
+
validate={validate}
|
|
56
|
+
onChange={props.updateStage}
|
|
57
|
+
render={(props: IFormikStageConfigInjectedProps) => <RouteLambdaFunctionStageForm {...props} />}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const initialize = () => {
|
|
64
|
+
HelpContentsRegistry.register('aws.lambdaDeploymentStage.lambda', 'Lambda Name');
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function validate(stageConfig: IStage) {
|
|
68
|
+
const validator = new FormValidator(stageConfig);
|
|
69
|
+
|
|
70
|
+
validator
|
|
71
|
+
.field('triggerArns', 'Trigger ARNs')
|
|
72
|
+
.optional()
|
|
73
|
+
.withValidators((value: any, _: string) => {
|
|
74
|
+
const tmp: any[] = value.map((arn: string) => {
|
|
75
|
+
return awsArnValidator(arn, arn);
|
|
76
|
+
});
|
|
77
|
+
const ret: boolean = tmp.every((el) => el === undefined);
|
|
78
|
+
return ret
|
|
79
|
+
? undefined
|
|
80
|
+
: 'Invalid ARN. Event ARN must match regular expression: /^arn:aws[a-zA-Z-]?:[a-zA-Z_0-9.-]+:./';
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return validator.validateForm();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line
|
|
87
|
+
export namespace RouteLambdaExecutionDetails {
|
|
88
|
+
export const title = 'Route Lambda Traffic Stage';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const lambdaRouteStage: IStageTypeConfig = {
|
|
92
|
+
key: 'Aws.LambdaTrafficRoutingStage',
|
|
93
|
+
label: `AWS Lambda Route`,
|
|
94
|
+
description: 'Route traffic across various versions of your Lambda function',
|
|
95
|
+
component: RouteLambdaConfig, // stage config
|
|
96
|
+
executionDetailsSections: [RouteLambdaExecutionDetails, ExecutionDetailsTasks],
|
|
97
|
+
validateFn: validate,
|
|
98
|
+
};
|