-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathS3Code.go
More file actions
292 lines (239 loc) · 7.17 KB
/
S3Code.go
File metadata and controls
292 lines (239 loc) · 7.17 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
package awslambda
import (
_init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii"
_jsii_ "github.com/aws/jsii-runtime-go/runtime"
"github.com/aws/aws-cdk-go/awscdk/v2"
"github.com/aws/aws-cdk-go/awscdk/v2/awsecr"
"github.com/aws/aws-cdk-go/awscdk/v2/awss3"
"github.com/aws/aws-cdk-go/awscdk/v2/awss3assets"
"github.com/aws/constructs-go/constructs/v10"
)
// Lambda code from an S3 archive.
//
// Example:
// // The code below shows an example of how to instantiate this type.
// // The values are placeholders you should change.
// import "github.com/aws/aws-cdk-go/awscdk"
// import "github.com/aws/aws-cdk-go/awscdk"
//
// var bucket Bucket
//
// s3Code := awscdk.Aws_lambda.NewS3Code(bucket, jsii.String("key"), jsii.String("objectVersion"))
//
type S3Code interface {
Code
// Determines whether this Code is inline code or not.
IsInline() *bool
// Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.
Bind(scope constructs.Construct) *CodeConfig
// Called after the CFN function resource has been created to allow the code class to bind to it.
//
// Specifically it's required to allow assets to add
// metadata for tooling like SAM CLI to be able to find their origins.
BindToResource(_resource awscdk.CfnResource, _options *ResourceBindOptions)
}
// The jsii proxy struct for S3Code
type jsiiProxy_S3Code struct {
jsiiProxy_Code
}
func (j *jsiiProxy_S3Code) IsInline() *bool {
var returns *bool
_jsii_.Get(
j,
"isInline",
&returns,
)
return returns
}
func NewS3Code(bucket awss3.IBucket, key *string, objectVersion *string) S3Code {
_init_.Initialize()
if err := validateNewS3CodeParameters(bucket, key); err != nil {
panic(err)
}
j := jsiiProxy_S3Code{}
_jsii_.Create(
"aws-cdk-lib.aws_lambda.S3Code",
[]interface{}{bucket, key, objectVersion},
&j,
)
return &j
}
func NewS3Code_Override(s S3Code, bucket awss3.IBucket, key *string, objectVersion *string) {
_init_.Initialize()
_jsii_.Create(
"aws-cdk-lib.aws_lambda.S3Code",
[]interface{}{bucket, key, objectVersion},
s,
)
}
// Loads the function code from a local disk path.
func S3Code_FromAsset(path *string, options *awss3assets.AssetOptions) AssetCode {
_init_.Initialize()
if err := validateS3Code_FromAssetParameters(path, options); err != nil {
panic(err)
}
var returns AssetCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromAsset",
[]interface{}{path, options},
&returns,
)
return returns
}
// Create an ECR image from the specified asset and bind it as the Lambda code.
func S3Code_FromAssetImage(directory *string, props *AssetImageCodeProps) AssetImageCode {
_init_.Initialize()
if err := validateS3Code_FromAssetImageParameters(directory, props); err != nil {
panic(err)
}
var returns AssetImageCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromAssetImage",
[]interface{}{directory, props},
&returns,
)
return returns
}
// Lambda handler code as an S3 object.
//
// Note: If `objectVersion` is not defined, the lambda will not be updated automatically if the code in the bucket is updated.
// This is because CDK/Cloudformation does not track changes on the source S3 Bucket. It is recommended to either use S3Code.fromAsset() instead or set objectVersion.
func S3Code_FromBucket(bucket awss3.IBucket, key *string, objectVersion *string) S3Code {
_init_.Initialize()
if err := validateS3Code_FromBucketParameters(bucket, key); err != nil {
panic(err)
}
var returns S3Code
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromBucket",
[]interface{}{bucket, key, objectVersion},
&returns,
)
return returns
}
// Lambda handler code as an S3 object.
//
// Note: If `options.objectVersion` is not defined, the lambda will not be updated automatically if the code in the bucket is updated.
// This is because CDK/Cloudformation does not track changes on the source S3 Bucket. It is recommended to either use S3Code.fromAsset() instead or set objectVersion.
func S3Code_FromBucketV2(bucket awss3.IBucket, key *string, options *BucketOptions) S3CodeV2 {
_init_.Initialize()
if err := validateS3Code_FromBucketV2Parameters(bucket, key, options); err != nil {
panic(err)
}
var returns S3CodeV2
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromBucketV2",
[]interface{}{bucket, key, options},
&returns,
)
return returns
}
// Creates a new Lambda source defined using CloudFormation parameters.
//
// Returns: a new instance of `CfnParametersCode`.
func S3Code_FromCfnParameters(props *CfnParametersCodeProps) CfnParametersCode {
_init_.Initialize()
if err := validateS3Code_FromCfnParametersParameters(props); err != nil {
panic(err)
}
var returns CfnParametersCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromCfnParameters",
[]interface{}{props},
&returns,
)
return returns
}
// Runs a command to build the code asset that will be used.
func S3Code_FromCustomCommand(output *string, command *[]*string, options *CustomCommandOptions) AssetCode {
_init_.Initialize()
if err := validateS3Code_FromCustomCommandParameters(output, command, options); err != nil {
panic(err)
}
var returns AssetCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromCustomCommand",
[]interface{}{output, command, options},
&returns,
)
return returns
}
// Loads the function code from an asset created by a Docker build.
//
// By default, the asset is expected to be located at `/asset` in the
// image.
func S3Code_FromDockerBuild(path *string, options *DockerBuildAssetOptions) AssetCode {
_init_.Initialize()
if err := validateS3Code_FromDockerBuildParameters(path, options); err != nil {
panic(err)
}
var returns AssetCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromDockerBuild",
[]interface{}{path, options},
&returns,
)
return returns
}
// Use an existing ECR image as the Lambda code.
func S3Code_FromEcrImage(repository awsecr.IRepository, props *EcrImageCodeProps) EcrImageCode {
_init_.Initialize()
if err := validateS3Code_FromEcrImageParameters(repository, props); err != nil {
panic(err)
}
var returns EcrImageCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromEcrImage",
[]interface{}{repository, props},
&returns,
)
return returns
}
// Inline code for Lambda handler.
//
// Returns: `LambdaInlineCode` with inline code.
func S3Code_FromInline(code *string) InlineCode {
_init_.Initialize()
if err := validateS3Code_FromInlineParameters(code); err != nil {
panic(err)
}
var returns InlineCode
_jsii_.StaticInvoke(
"aws-cdk-lib.aws_lambda.S3Code",
"fromInline",
[]interface{}{code},
&returns,
)
return returns
}
func (s *jsiiProxy_S3Code) Bind(scope constructs.Construct) *CodeConfig {
if err := s.validateBindParameters(scope); err != nil {
panic(err)
}
var returns *CodeConfig
_jsii_.Invoke(
s,
"bind",
[]interface{}{scope},
&returns,
)
return returns
}
func (s *jsiiProxy_S3Code) BindToResource(_resource awscdk.CfnResource, _options *ResourceBindOptions) {
if err := s.validateBindToResourceParameters(_resource, _options); err != nil {
panic(err)
}
_jsii_.InvokeVoid(
s,
"bindToResource",
[]interface{}{_resource, _options},
)
}