-
Notifications
You must be signed in to change notification settings - Fork 17
/
Location.go
148 lines (145 loc) · 5.63 KB
/
Location.go
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package awss3
// An interface that represents the location of a specific object in an S3 Bucket.
//
// Example:
// lambdaStack := cdk.NewStack(app, jsii.String("LambdaStack"))
// lambdaCode := lambda.Code_FromCfnParameters()
// lambda.NewFunction(lambdaStack, jsii.String("Lambda"), &FunctionProps{
// Code: lambdaCode,
// Handler: jsii.String("index.handler"),
// Runtime: lambda.Runtime_NODEJS_LATEST(),
// })
// // other resources that your Lambda needs, added to the lambdaStack...
//
// pipelineStack := cdk.NewStack(app, jsii.String("PipelineStack"))
// pipeline := codepipeline.NewPipeline(pipelineStack, jsii.String("Pipeline"))
//
// // add the source code repository containing this code to your Pipeline,
// // and the source code of the Lambda Function, if they're separate
// cdkSourceOutput := codepipeline.NewArtifact()
// cdkSourceAction := codepipeline_actions.NewCodeCommitSourceAction(&CodeCommitSourceActionProps{
// Repository: codecommit.NewRepository(pipelineStack, jsii.String("CdkCodeRepo"), &RepositoryProps{
// RepositoryName: jsii.String("CdkCodeRepo"),
// }),
// ActionName: jsii.String("CdkCode_Source"),
// Output: cdkSourceOutput,
// })
// lambdaSourceOutput := codepipeline.NewArtifact()
// lambdaSourceAction := codepipeline_actions.NewCodeCommitSourceAction(&CodeCommitSourceActionProps{
// Repository: codecommit.NewRepository(pipelineStack, jsii.String("LambdaCodeRepo"), &RepositoryProps{
// RepositoryName: jsii.String("LambdaCodeRepo"),
// }),
// ActionName: jsii.String("LambdaCode_Source"),
// Output: lambdaSourceOutput,
// })
// pipeline.AddStage(&StageOptions{
// StageName: jsii.String("Source"),
// Actions: []iAction{
// cdkSourceAction,
// lambdaSourceAction,
// },
// })
//
// // synthesize the Lambda CDK template, using CodeBuild
// // the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
// // adjust the build environment and/or commands accordingly
// cdkBuildProject := codebuild.NewProject(pipelineStack, jsii.String("CdkBuildProject"), &ProjectProps{
// Environment: &BuildEnvironment{
// BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
// },
// BuildSpec: codebuild.BuildSpec_FromObject(map[string]interface{}{
// "version": jsii.String("0.2"),
// "phases": map[string]map[string]*string{
// "install": map[string]*string{
// "commands": jsii.String("npm install"),
// },
// "build": map[string][]*string{
// "commands": []*string{
// jsii.String("npm run build"),
// jsii.String("npm run cdk synth LambdaStack -- -o ."),
// },
// },
// },
// "artifacts": map[string]*string{
// "files": jsii.String("LambdaStack.template.yaml"),
// },
// }),
// })
// cdkBuildOutput := codepipeline.NewArtifact()
// cdkBuildAction := codepipeline_actions.NewCodeBuildAction(&CodeBuildActionProps{
// ActionName: jsii.String("CDK_Build"),
// Project: cdkBuildProject,
// Input: cdkSourceOutput,
// Outputs: []artifact{
// cdkBuildOutput,
// },
// })
//
// // build your Lambda code, using CodeBuild
// // again, this example assumes your Lambda is written in TypeScript/JavaScript -
// // make sure to adjust the build environment and/or commands if they don't match your specific situation
// lambdaBuildProject := codebuild.NewProject(pipelineStack, jsii.String("LambdaBuildProject"), &ProjectProps{
// Environment: &BuildEnvironment{
// BuildImage: codebuild.LinuxBuildImage_STANDARD_7_0(),
// },
// BuildSpec: codebuild.BuildSpec_*FromObject(map[string]interface{}{
// "version": jsii.String("0.2"),
// "phases": map[string]map[string]*string{
// "install": map[string]*string{
// "commands": jsii.String("npm install"),
// },
// "build": map[string]*string{
// "commands": jsii.String("npm run build"),
// },
// },
// "artifacts": map[string][]*string{
// "files": []*string{
// jsii.String("index.js"),
// jsii.String("node_modules/**/*"),
// },
// },
// }),
// })
// lambdaBuildOutput := codepipeline.NewArtifact()
// lambdaBuildAction := codepipeline_actions.NewCodeBuildAction(&CodeBuildActionProps{
// ActionName: jsii.String("Lambda_Build"),
// Project: lambdaBuildProject,
// Input: lambdaSourceOutput,
// Outputs: []*artifact{
// lambdaBuildOutput,
// },
// })
//
// pipeline.AddStage(&StageOptions{
// StageName: jsii.String("Build"),
// Actions: []*iAction{
// cdkBuildAction,
// lambdaBuildAction,
// },
// })
//
// // finally, deploy your Lambda Stack
// pipeline.AddStage(&StageOptions{
// StageName: jsii.String("Deploy"),
// Actions: []*iAction{
// codepipeline_actions.NewCloudFormationCreateUpdateStackAction(&CloudFormationCreateUpdateStackActionProps{
// ActionName: jsii.String("Lambda_CFN_Deploy"),
// TemplatePath: cdkBuildOutput.AtPath(jsii.String("LambdaStack.template.yaml")),
// StackName: jsii.String("LambdaStackDeployedName"),
// AdminPermissions: jsii.Boolean(true),
// ParameterOverrides: lambdaCode.Assign(lambdaBuildOutput.s3Location),
// ExtraInputs: []*artifact{
// lambdaBuildOutput,
// },
// }),
// },
// })
//
type Location struct {
// The name of the S3 Bucket the object is in.
BucketName *string `field:"required" json:"bucketName" yaml:"bucketName"`
// The path inside the Bucket where the object is located at.
ObjectKey *string `field:"required" json:"objectKey" yaml:"objectKey"`
// The S3 object version.
ObjectVersion *string `field:"optional" json:"objectVersion" yaml:"objectVersion"`
}