-
Notifications
You must be signed in to change notification settings - Fork 50
/
getAccountSAS.go
241 lines (216 loc) · 10.1 KB
/
getAccountSAS.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
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package storage
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this data source to obtain a Shared Access Signature (SAS Token) for an existing Storage Account.
//
// Shared access signatures allow fine-grained, ephemeral access control to various aspects of an Azure Storage Account.
//
// Note that this is an [Account SAS](https://docs.microsoft.com/rest/api/storageservices/constructing-an-account-sas)
// and *not* a [Service SAS](https://docs.microsoft.com/rest/api/storageservices/constructing-a-service-sas).
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// exampleAccount, err := storage.NewAccount(ctx, "exampleAccount", &storage.AccountArgs{
// ResourceGroupName: exampleResourceGroup.Name,
// Location: exampleResourceGroup.Location,
// AccountTier: pulumi.String("Standard"),
// AccountReplicationType: pulumi.String("GRS"),
// Tags: pulumi.StringMap{
// "environment": pulumi.String("staging"),
// },
// })
// if err != nil {
// return err
// }
// exampleAccountSAS := storage.GetAccountSASOutput(ctx, storage.GetAccountSASOutputArgs{
// ConnectionString: exampleAccount.PrimaryConnectionString,
// HttpsOnly: pulumi.Bool(true),
// SignedVersion: pulumi.String("2017-07-29"),
// ResourceTypes: &storage.GetAccountSASResourceTypesArgs{
// Service: pulumi.Bool(true),
// Container: pulumi.Bool(false),
// Object: pulumi.Bool(false),
// },
// Services: &storage.GetAccountSASServicesArgs{
// Blob: pulumi.Bool(true),
// Queue: pulumi.Bool(false),
// Table: pulumi.Bool(false),
// File: pulumi.Bool(false),
// },
// Start: pulumi.String("2018-03-21T00:00:00Z"),
// Expiry: pulumi.String("2020-03-21T00:00:00Z"),
// Permissions: &storage.GetAccountSASPermissionsArgs{
// Read: pulumi.Bool(true),
// Write: pulumi.Bool(true),
// Delete: pulumi.Bool(false),
// List: pulumi.Bool(false),
// Add: pulumi.Bool(true),
// Create: pulumi.Bool(true),
// Update: pulumi.Bool(false),
// Process: pulumi.Bool(false),
// Tag: pulumi.Bool(false),
// Filter: pulumi.Bool(false),
// },
// }, nil)
// ctx.Export("sasUrlQueryString", exampleAccountSAS.ApplyT(func(exampleAccountSAS storage.GetAccountSASResult) (string, error) {
// return exampleAccountSAS.Sas, nil
// }).(pulumi.StringOutput))
// return nil
// })
// }
//
// ```
func GetAccountSAS(ctx *pulumi.Context, args *GetAccountSASArgs, opts ...pulumi.InvokeOption) (*GetAccountSASResult, error) {
var rv GetAccountSASResult
err := ctx.Invoke("azure:storage/getAccountSAS:getAccountSAS", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getAccountSAS.
type GetAccountSASArgs struct {
// The connection string for the storage account to which this SAS applies. Typically directly from the `primaryConnectionString` attribute of a `storage.Account` resource.
ConnectionString string `pulumi:"connectionString"`
// The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
Expiry string `pulumi:"expiry"`
// Only permit `https` access. If `false`, both `http` and `https` are permitted. Defaults to `true`.
HttpsOnly *bool `pulumi:"httpsOnly"`
// IP address, or a range of IP addresses, from which to accept requests. When specifying a range, note that the range is inclusive.
IpAddresses *string `pulumi:"ipAddresses"`
// A `permissions` block as defined below.
Permissions GetAccountSASPermissions `pulumi:"permissions"`
// A `resourceTypes` block as defined below.
ResourceTypes GetAccountSASResourceTypes `pulumi:"resourceTypes"`
// A `services` block as defined below.
Services GetAccountSASServices `pulumi:"services"`
// Specifies the signed storage service version to use to authorize requests made with this account SAS. Defaults to `2017-07-29`.
SignedVersion *string `pulumi:"signedVersion"`
// The starting time and date of validity of this SAS. Must be a valid ISO-8601 format time/date string.
Start string `pulumi:"start"`
}
// A collection of values returned by getAccountSAS.
type GetAccountSASResult struct {
ConnectionString string `pulumi:"connectionString"`
Expiry string `pulumi:"expiry"`
HttpsOnly *bool `pulumi:"httpsOnly"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
IpAddresses *string `pulumi:"ipAddresses"`
Permissions GetAccountSASPermissions `pulumi:"permissions"`
ResourceTypes GetAccountSASResourceTypes `pulumi:"resourceTypes"`
// The computed Account Shared Access Signature (SAS).
Sas string `pulumi:"sas"`
Services GetAccountSASServices `pulumi:"services"`
SignedVersion *string `pulumi:"signedVersion"`
Start string `pulumi:"start"`
}
func GetAccountSASOutput(ctx *pulumi.Context, args GetAccountSASOutputArgs, opts ...pulumi.InvokeOption) GetAccountSASResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetAccountSASResult, error) {
args := v.(GetAccountSASArgs)
r, err := GetAccountSAS(ctx, &args, opts...)
var s GetAccountSASResult
if r != nil {
s = *r
}
return s, err
}).(GetAccountSASResultOutput)
}
// A collection of arguments for invoking getAccountSAS.
type GetAccountSASOutputArgs struct {
// The connection string for the storage account to which this SAS applies. Typically directly from the `primaryConnectionString` attribute of a `storage.Account` resource.
ConnectionString pulumi.StringInput `pulumi:"connectionString"`
// The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
Expiry pulumi.StringInput `pulumi:"expiry"`
// Only permit `https` access. If `false`, both `http` and `https` are permitted. Defaults to `true`.
HttpsOnly pulumi.BoolPtrInput `pulumi:"httpsOnly"`
// IP address, or a range of IP addresses, from which to accept requests. When specifying a range, note that the range is inclusive.
IpAddresses pulumi.StringPtrInput `pulumi:"ipAddresses"`
// A `permissions` block as defined below.
Permissions GetAccountSASPermissionsInput `pulumi:"permissions"`
// A `resourceTypes` block as defined below.
ResourceTypes GetAccountSASResourceTypesInput `pulumi:"resourceTypes"`
// A `services` block as defined below.
Services GetAccountSASServicesInput `pulumi:"services"`
// Specifies the signed storage service version to use to authorize requests made with this account SAS. Defaults to `2017-07-29`.
SignedVersion pulumi.StringPtrInput `pulumi:"signedVersion"`
// The starting time and date of validity of this SAS. Must be a valid ISO-8601 format time/date string.
Start pulumi.StringInput `pulumi:"start"`
}
func (GetAccountSASOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetAccountSASArgs)(nil)).Elem()
}
// A collection of values returned by getAccountSAS.
type GetAccountSASResultOutput struct{ *pulumi.OutputState }
func (GetAccountSASResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetAccountSASResult)(nil)).Elem()
}
func (o GetAccountSASResultOutput) ToGetAccountSASResultOutput() GetAccountSASResultOutput {
return o
}
func (o GetAccountSASResultOutput) ToGetAccountSASResultOutputWithContext(ctx context.Context) GetAccountSASResultOutput {
return o
}
func (o GetAccountSASResultOutput) ConnectionString() pulumi.StringOutput {
return o.ApplyT(func(v GetAccountSASResult) string { return v.ConnectionString }).(pulumi.StringOutput)
}
func (o GetAccountSASResultOutput) Expiry() pulumi.StringOutput {
return o.ApplyT(func(v GetAccountSASResult) string { return v.Expiry }).(pulumi.StringOutput)
}
func (o GetAccountSASResultOutput) HttpsOnly() pulumi.BoolPtrOutput {
return o.ApplyT(func(v GetAccountSASResult) *bool { return v.HttpsOnly }).(pulumi.BoolPtrOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o GetAccountSASResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v GetAccountSASResult) string { return v.Id }).(pulumi.StringOutput)
}
func (o GetAccountSASResultOutput) IpAddresses() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetAccountSASResult) *string { return v.IpAddresses }).(pulumi.StringPtrOutput)
}
func (o GetAccountSASResultOutput) Permissions() GetAccountSASPermissionsOutput {
return o.ApplyT(func(v GetAccountSASResult) GetAccountSASPermissions { return v.Permissions }).(GetAccountSASPermissionsOutput)
}
func (o GetAccountSASResultOutput) ResourceTypes() GetAccountSASResourceTypesOutput {
return o.ApplyT(func(v GetAccountSASResult) GetAccountSASResourceTypes { return v.ResourceTypes }).(GetAccountSASResourceTypesOutput)
}
// The computed Account Shared Access Signature (SAS).
func (o GetAccountSASResultOutput) Sas() pulumi.StringOutput {
return o.ApplyT(func(v GetAccountSASResult) string { return v.Sas }).(pulumi.StringOutput)
}
func (o GetAccountSASResultOutput) Services() GetAccountSASServicesOutput {
return o.ApplyT(func(v GetAccountSASResult) GetAccountSASServices { return v.Services }).(GetAccountSASServicesOutput)
}
func (o GetAccountSASResultOutput) SignedVersion() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetAccountSASResult) *string { return v.SignedVersion }).(pulumi.StringPtrOutput)
}
func (o GetAccountSASResultOutput) Start() pulumi.StringOutput {
return o.ApplyT(func(v GetAccountSASResult) string { return v.Start }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(GetAccountSASResultOutput{})
}