/
deployment.go
353 lines (293 loc) · 14.7 KB
/
deployment.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package apigateway
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Manages an API Gateway REST Deployment. A deployment is a snapshot of the REST API configuration. The deployment can then be published to callable endpoints via the `apigateway.Stage` resource and optionally managed further with the `apigateway.BasePathMapping` resource, `apigateway.DomainName` resource, and `awsApiMethodSettings` resource. For more information, see the [API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-deploy-api.html).
//
// To properly capture all REST API configuration in a deployment, this resource must have dependencies on all prior resources that manage resources/paths, methods, integrations, etc.
//
// * For REST APIs that are configured via OpenAPI specification (`apigateway.RestApi` resource `body` argument), no special dependency setup is needed beyond referencing the `id` attribute of that resource unless additional resources have further customized the REST API.
// * When the REST API configuration involves other resources (`apigateway.Integration` resource), the dependency setup can be done with implicit resource references in the `triggers` argument or explicit resource references using the [resource `dependsOn` custom option](https://www.pulumi.com/docs/intro/concepts/resources/#dependson). The `triggers` argument should be preferred over `dependsOn`, since `dependsOn` can only capture dependency ordering and will not cause the resource to recreate (redeploy the REST API) with upstream configuration changes.
//
// !> **WARNING:** It is recommended to use the `apigateway.Stage` resource instead of managing an API Gateway Stage via the `stageName` argument of this resource. When this resource is recreated (REST API redeployment) with the `stageName` configured, the stage is deleted and recreated. This will cause a temporary service interruption, increase provide plan differences, and can require a second apply to recreate any downstream stage configuration such as associated `awsApiMethodSettings` resources.
//
// ## Example Usage
type Deployment struct {
pulumi.CustomResourceState
// The creation date of the deployment
CreatedDate pulumi.StringOutput `pulumi:"createdDate"`
// Description of the deployment
Description pulumi.StringPtrOutput `pulumi:"description"`
// The execution ARN to be used in `lambdaPermission` resource's `sourceArn`
// when allowing API Gateway to invoke a Lambda function,
// e.g. `arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j/prod`
ExecutionArn pulumi.StringOutput `pulumi:"executionArn"`
// The URL to invoke the API pointing to the stage,
// e.g. `https://z4675bid1j.execute-api.eu-west-2.amazonaws.com/prod`
InvokeUrl pulumi.StringOutput `pulumi:"invokeUrl"`
// REST API identifier.
RestApi pulumi.StringOutput `pulumi:"restApi"`
// Description to set on the stage managed by the `stageName` argument.
StageDescription pulumi.StringPtrOutput `pulumi:"stageDescription"`
// Name of the stage to create with this deployment. If the specified stage already exists, it will be updated to point to the new deployment. It is recommended to use the `apigateway.Stage` resource instead to manage stages.
StageName pulumi.StringPtrOutput `pulumi:"stageName"`
// Map of arbitrary keys and values that, when changed, will trigger a redeployment.
Triggers pulumi.StringMapOutput `pulumi:"triggers"`
// Map to set on the stage managed by the `stageName` argument.
Variables pulumi.StringMapOutput `pulumi:"variables"`
}
// NewDeployment registers a new resource with the given unique name, arguments, and options.
func NewDeployment(ctx *pulumi.Context,
name string, args *DeploymentArgs, opts ...pulumi.ResourceOption) (*Deployment, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.RestApi == nil {
return nil, errors.New("invalid value for required argument 'RestApi'")
}
var resource Deployment
err := ctx.RegisterResource("aws:apigateway/deployment:Deployment", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDeployment gets an existing Deployment resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetDeployment(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DeploymentState, opts ...pulumi.ResourceOption) (*Deployment, error) {
var resource Deployment
err := ctx.ReadResource("aws:apigateway/deployment:Deployment", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Deployment resources.
type deploymentState struct {
// The creation date of the deployment
CreatedDate *string `pulumi:"createdDate"`
// Description of the deployment
Description *string `pulumi:"description"`
// The execution ARN to be used in `lambdaPermission` resource's `sourceArn`
// when allowing API Gateway to invoke a Lambda function,
// e.g. `arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j/prod`
ExecutionArn *string `pulumi:"executionArn"`
// The URL to invoke the API pointing to the stage,
// e.g. `https://z4675bid1j.execute-api.eu-west-2.amazonaws.com/prod`
InvokeUrl *string `pulumi:"invokeUrl"`
// REST API identifier.
RestApi *string `pulumi:"restApi"`
// Description to set on the stage managed by the `stageName` argument.
StageDescription *string `pulumi:"stageDescription"`
// Name of the stage to create with this deployment. If the specified stage already exists, it will be updated to point to the new deployment. It is recommended to use the `apigateway.Stage` resource instead to manage stages.
StageName *string `pulumi:"stageName"`
// Map of arbitrary keys and values that, when changed, will trigger a redeployment.
Triggers map[string]string `pulumi:"triggers"`
// Map to set on the stage managed by the `stageName` argument.
Variables map[string]string `pulumi:"variables"`
}
type DeploymentState struct {
// The creation date of the deployment
CreatedDate pulumi.StringPtrInput
// Description of the deployment
Description pulumi.StringPtrInput
// The execution ARN to be used in `lambdaPermission` resource's `sourceArn`
// when allowing API Gateway to invoke a Lambda function,
// e.g. `arn:aws:execute-api:eu-west-2:123456789012:z4675bid1j/prod`
ExecutionArn pulumi.StringPtrInput
// The URL to invoke the API pointing to the stage,
// e.g. `https://z4675bid1j.execute-api.eu-west-2.amazonaws.com/prod`
InvokeUrl pulumi.StringPtrInput
// REST API identifier.
RestApi pulumi.StringPtrInput
// Description to set on the stage managed by the `stageName` argument.
StageDescription pulumi.StringPtrInput
// Name of the stage to create with this deployment. If the specified stage already exists, it will be updated to point to the new deployment. It is recommended to use the `apigateway.Stage` resource instead to manage stages.
StageName pulumi.StringPtrInput
// Map of arbitrary keys and values that, when changed, will trigger a redeployment.
Triggers pulumi.StringMapInput
// Map to set on the stage managed by the `stageName` argument.
Variables pulumi.StringMapInput
}
func (DeploymentState) ElementType() reflect.Type {
return reflect.TypeOf((*deploymentState)(nil)).Elem()
}
type deploymentArgs struct {
// Description of the deployment
Description *string `pulumi:"description"`
// REST API identifier.
RestApi interface{} `pulumi:"restApi"`
// Description to set on the stage managed by the `stageName` argument.
StageDescription *string `pulumi:"stageDescription"`
// Name of the stage to create with this deployment. If the specified stage already exists, it will be updated to point to the new deployment. It is recommended to use the `apigateway.Stage` resource instead to manage stages.
StageName *string `pulumi:"stageName"`
// Map of arbitrary keys and values that, when changed, will trigger a redeployment.
Triggers map[string]string `pulumi:"triggers"`
// Map to set on the stage managed by the `stageName` argument.
Variables map[string]string `pulumi:"variables"`
}
// The set of arguments for constructing a Deployment resource.
type DeploymentArgs struct {
// Description of the deployment
Description pulumi.StringPtrInput
// REST API identifier.
RestApi pulumi.Input
// Description to set on the stage managed by the `stageName` argument.
StageDescription pulumi.StringPtrInput
// Name of the stage to create with this deployment. If the specified stage already exists, it will be updated to point to the new deployment. It is recommended to use the `apigateway.Stage` resource instead to manage stages.
StageName pulumi.StringPtrInput
// Map of arbitrary keys and values that, when changed, will trigger a redeployment.
Triggers pulumi.StringMapInput
// Map to set on the stage managed by the `stageName` argument.
Variables pulumi.StringMapInput
}
func (DeploymentArgs) ElementType() reflect.Type {
return reflect.TypeOf((*deploymentArgs)(nil)).Elem()
}
type DeploymentInput interface {
pulumi.Input
ToDeploymentOutput() DeploymentOutput
ToDeploymentOutputWithContext(ctx context.Context) DeploymentOutput
}
func (*Deployment) ElementType() reflect.Type {
return reflect.TypeOf((*Deployment)(nil))
}
func (i *Deployment) ToDeploymentOutput() DeploymentOutput {
return i.ToDeploymentOutputWithContext(context.Background())
}
func (i *Deployment) ToDeploymentOutputWithContext(ctx context.Context) DeploymentOutput {
return pulumi.ToOutputWithContext(ctx, i).(DeploymentOutput)
}
func (i *Deployment) ToDeploymentPtrOutput() DeploymentPtrOutput {
return i.ToDeploymentPtrOutputWithContext(context.Background())
}
func (i *Deployment) ToDeploymentPtrOutputWithContext(ctx context.Context) DeploymentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(DeploymentPtrOutput)
}
type DeploymentPtrInput interface {
pulumi.Input
ToDeploymentPtrOutput() DeploymentPtrOutput
ToDeploymentPtrOutputWithContext(ctx context.Context) DeploymentPtrOutput
}
type deploymentPtrType DeploymentArgs
func (*deploymentPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**Deployment)(nil))
}
func (i *deploymentPtrType) ToDeploymentPtrOutput() DeploymentPtrOutput {
return i.ToDeploymentPtrOutputWithContext(context.Background())
}
func (i *deploymentPtrType) ToDeploymentPtrOutputWithContext(ctx context.Context) DeploymentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(DeploymentPtrOutput)
}
// DeploymentArrayInput is an input type that accepts DeploymentArray and DeploymentArrayOutput values.
// You can construct a concrete instance of `DeploymentArrayInput` via:
//
// DeploymentArray{ DeploymentArgs{...} }
type DeploymentArrayInput interface {
pulumi.Input
ToDeploymentArrayOutput() DeploymentArrayOutput
ToDeploymentArrayOutputWithContext(context.Context) DeploymentArrayOutput
}
type DeploymentArray []DeploymentInput
func (DeploymentArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*Deployment)(nil))
}
func (i DeploymentArray) ToDeploymentArrayOutput() DeploymentArrayOutput {
return i.ToDeploymentArrayOutputWithContext(context.Background())
}
func (i DeploymentArray) ToDeploymentArrayOutputWithContext(ctx context.Context) DeploymentArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(DeploymentArrayOutput)
}
// DeploymentMapInput is an input type that accepts DeploymentMap and DeploymentMapOutput values.
// You can construct a concrete instance of `DeploymentMapInput` via:
//
// DeploymentMap{ "key": DeploymentArgs{...} }
type DeploymentMapInput interface {
pulumi.Input
ToDeploymentMapOutput() DeploymentMapOutput
ToDeploymentMapOutputWithContext(context.Context) DeploymentMapOutput
}
type DeploymentMap map[string]DeploymentInput
func (DeploymentMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*Deployment)(nil))
}
func (i DeploymentMap) ToDeploymentMapOutput() DeploymentMapOutput {
return i.ToDeploymentMapOutputWithContext(context.Background())
}
func (i DeploymentMap) ToDeploymentMapOutputWithContext(ctx context.Context) DeploymentMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(DeploymentMapOutput)
}
type DeploymentOutput struct {
*pulumi.OutputState
}
func (DeploymentOutput) ElementType() reflect.Type {
return reflect.TypeOf((*Deployment)(nil))
}
func (o DeploymentOutput) ToDeploymentOutput() DeploymentOutput {
return o
}
func (o DeploymentOutput) ToDeploymentOutputWithContext(ctx context.Context) DeploymentOutput {
return o
}
func (o DeploymentOutput) ToDeploymentPtrOutput() DeploymentPtrOutput {
return o.ToDeploymentPtrOutputWithContext(context.Background())
}
func (o DeploymentOutput) ToDeploymentPtrOutputWithContext(ctx context.Context) DeploymentPtrOutput {
return o.ApplyT(func(v Deployment) *Deployment {
return &v
}).(DeploymentPtrOutput)
}
type DeploymentPtrOutput struct {
*pulumi.OutputState
}
func (DeploymentPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Deployment)(nil))
}
func (o DeploymentPtrOutput) ToDeploymentPtrOutput() DeploymentPtrOutput {
return o
}
func (o DeploymentPtrOutput) ToDeploymentPtrOutputWithContext(ctx context.Context) DeploymentPtrOutput {
return o
}
type DeploymentArrayOutput struct{ *pulumi.OutputState }
func (DeploymentArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]Deployment)(nil))
}
func (o DeploymentArrayOutput) ToDeploymentArrayOutput() DeploymentArrayOutput {
return o
}
func (o DeploymentArrayOutput) ToDeploymentArrayOutputWithContext(ctx context.Context) DeploymentArrayOutput {
return o
}
func (o DeploymentArrayOutput) Index(i pulumi.IntInput) DeploymentOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) Deployment {
return vs[0].([]Deployment)[vs[1].(int)]
}).(DeploymentOutput)
}
type DeploymentMapOutput struct{ *pulumi.OutputState }
func (DeploymentMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]Deployment)(nil))
}
func (o DeploymentMapOutput) ToDeploymentMapOutput() DeploymentMapOutput {
return o
}
func (o DeploymentMapOutput) ToDeploymentMapOutputWithContext(ctx context.Context) DeploymentMapOutput {
return o
}
func (o DeploymentMapOutput) MapIndex(k pulumi.StringInput) DeploymentOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) Deployment {
return vs[0].(map[string]Deployment)[vs[1].(string)]
}).(DeploymentOutput)
}
func init() {
pulumi.RegisterOutputType(DeploymentOutput{})
pulumi.RegisterOutputType(DeploymentPtrOutput{})
pulumi.RegisterOutputType(DeploymentArrayOutput{})
pulumi.RegisterOutputType(DeploymentMapOutput{})
}