/
deploy-action.ts
87 lines (75 loc) · 2.29 KB
/
deploy-action.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import * as codepipeline from '@aws-cdk/aws-codepipeline';
import { SecretValue } from '@aws-cdk/core';
import { Action } from '../action';
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main
// eslint-disable-next-line no-duplicate-imports, import/order
import { Construct } from '@aws-cdk/core';
/**
* Construction properties of the {@link AlexaSkillDeployAction Alexa deploy Action}.
*/
export interface AlexaSkillDeployActionProps extends codepipeline.CommonActionProps {
/**
* The client id of the developer console token
*/
readonly clientId: string;
/**
* The client secret of the developer console token
*/
readonly clientSecret: SecretValue;
/**
* The refresh token of the developer console token
*/
readonly refreshToken: SecretValue;
/**
* The Alexa skill id
*/
readonly skillId: string;
/**
* The source artifact containing the voice model and skill manifest
*/
readonly input: codepipeline.Artifact;
/**
* An optional artifact containing overrides for the skill manifest
*/
readonly parameterOverridesArtifact?: codepipeline.Artifact;
}
/**
* Deploys the skill to Alexa
*/
export class AlexaSkillDeployAction extends Action {
private readonly props: AlexaSkillDeployActionProps;
constructor(props: AlexaSkillDeployActionProps) {
super({
...props,
category: codepipeline.ActionCategory.DEPLOY,
owner: 'ThirdParty',
provider: 'AlexaSkillsKit',
artifactBounds: {
minInputs: 1,
maxInputs: 2,
minOutputs: 0,
maxOutputs: 0,
},
inputs: getInputs(props),
});
this.props = props;
}
protected bound(_scope: Construct, _stage: codepipeline.IStage, _options: codepipeline.ActionBindOptions):
codepipeline.ActionConfig {
return {
configuration: {
ClientId: this.props.clientId,
ClientSecret: this.props.clientSecret.unsafeUnwrap(), // Safe usage
RefreshToken: this.props.refreshToken.unsafeUnwrap(), // Safe usage
SkillId: this.props.skillId,
},
};
}
}
function getInputs(props: AlexaSkillDeployActionProps): codepipeline.Artifact[] {
const ret = [props.input];
if (props.parameterOverridesArtifact) {
ret.push(props.parameterOverridesArtifact);
}
return ret;
}