猿问

Pulumi 意外地对共享访问签名 (SAS) 的某些部分进行编码

我们在下面提供了 golang 代码,用于从 Azure 获取共享访问签名。它的工作原理是,但是打印的sas有一些字段,即“日期字段”,错误地编码了。


...


conStr := ConvertPulumiStringToString(account.PrimaryConnectionString)

httpsOnly := true

now := time.Now()


sas, err := storage.GetAccountBlobContainerSAS(ctx, &storage.GetAccountBlobContainerSASArgs{

        ConnectionString:   <-conStr,

        ContainerName:      "container",

        Expiry:             now.AddDate(10, 0, 0).Format(time.RFC3339),

        HttpsOnly:          &httpsOnly,

        Permissions: storage.GetAccountBlobContainerSASPermissions{

            Add:    false,

            Create: false,

            Delete: false,

            List:   true,

            Read:   true,

            Write:  false,

        },

        Start: now.Format(time.RFC3339),

    })

    println(sas.Sas)

我们得到这个st=2021-03-16T10%3A58%3A24%2B01%3A00


我们期望这种格式st=2021-03-16T10:16:30Z


我尝试过查看pulumi文档,但它非常有限。


任何帮助是值得赞赏的。


烙印99
浏览 109回答 1
1回答

江户川乱折腾

问题是,使用 RFC3339 时,时区需要为 UTC 才能与 Azure 和 pulumi 配合使用。conStr := ConvertPulumiStringToString(account.PrimaryConnectionString)httpsOnly := truenow := time.Now().UTC()sas, err := storage.GetAccountBlobContainerSAS(ctx, &storage.GetAccountBlobContainerSASArgs{&nbsp; &nbsp; &nbsp; &nbsp; ConnectionString:&nbsp; &nbsp;<-conStr,&nbsp; &nbsp; &nbsp; &nbsp; ContainerName:&nbsp; &nbsp; &nbsp; "container",&nbsp; &nbsp; &nbsp; &nbsp; Expiry:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;now.AddDate(10, 0, 0).Format(time.RFC3339),&nbsp; &nbsp; &nbsp; &nbsp; HttpsOnly:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &httpsOnly,&nbsp; &nbsp; &nbsp; &nbsp; Permissions: storage.GetAccountBlobContainerSASPermissions{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Add:&nbsp; &nbsp; false,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Create: false,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Delete: false,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List:&nbsp; &nbsp;true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Read:&nbsp; &nbsp;true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write:&nbsp; false,&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; Start: now.Format(time.RFC3339),&nbsp; &nbsp; })&nbsp; &nbsp; println(sas.Sas)
随时随地看视频慕课网APP

相关分类

Go
我要回答