github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/secretsmanager/getSecretVersion.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package secretsmanager 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Retrieve information about a Secrets Manager secret version, including its secret value. To retrieve secret metadata, see the `secretsmanager.Secret` data source. 15 // 16 // ## Example Usage 17 // 18 // ### Retrieve Current Secret Version 19 // 20 // By default, this data sources retrieves information based on the `AWSCURRENT` staging label. 21 // 22 // <!--Start PulumiCodeChooser --> 23 // ```go 24 // package main 25 // 26 // import ( 27 // 28 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/secretsmanager" 29 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 30 // 31 // ) 32 // 33 // func main() { 34 // pulumi.Run(func(ctx *pulumi.Context) error { 35 // _, err := secretsmanager.LookupSecretVersion(ctx, &secretsmanager.LookupSecretVersionArgs{ 36 // SecretId: example.Id, 37 // }, nil) 38 // if err != nil { 39 // return err 40 // } 41 // return nil 42 // }) 43 // } 44 // 45 // ``` 46 // <!--End PulumiCodeChooser --> 47 // 48 // ### Retrieve Specific Secret Version 49 // 50 // <!--Start PulumiCodeChooser --> 51 // ```go 52 // package main 53 // 54 // import ( 55 // 56 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/secretsmanager" 57 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 58 // 59 // ) 60 // 61 // func main() { 62 // pulumi.Run(func(ctx *pulumi.Context) error { 63 // _, err := secretsmanager.LookupSecretVersion(ctx, &secretsmanager.LookupSecretVersionArgs{ 64 // SecretId: example.Id, 65 // VersionStage: pulumi.StringRef("example"), 66 // }, nil) 67 // if err != nil { 68 // return err 69 // } 70 // return nil 71 // }) 72 // } 73 // 74 // ``` 75 // <!--End PulumiCodeChooser --> 76 func LookupSecretVersion(ctx *pulumi.Context, args *LookupSecretVersionArgs, opts ...pulumi.InvokeOption) (*LookupSecretVersionResult, error) { 77 opts = internal.PkgInvokeDefaultOpts(opts) 78 var rv LookupSecretVersionResult 79 err := ctx.Invoke("aws:secretsmanager/getSecretVersion:getSecretVersion", args, &rv, opts...) 80 if err != nil { 81 return nil, err 82 } 83 return &rv, nil 84 } 85 86 // A collection of arguments for invoking getSecretVersion. 87 type LookupSecretVersionArgs struct { 88 // Specifies the secret containing the version that you want to retrieve. You can specify either the ARN or the friendly name of the secret. 89 SecretId string `pulumi:"secretId"` 90 // Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides `versionStage`. 91 VersionId *string `pulumi:"versionId"` 92 // Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to `AWSCURRENT`. 93 VersionStage *string `pulumi:"versionStage"` 94 } 95 96 // A collection of values returned by getSecretVersion. 97 type LookupSecretVersionResult struct { 98 // ARN of the secret. 99 Arn string `pulumi:"arn"` 100 // Created date of the secret in UTC. 101 CreatedDate string `pulumi:"createdDate"` 102 // The provider-assigned unique ID for this managed resource. 103 Id string `pulumi:"id"` 104 // Decrypted part of the protected secret information that was originally provided as a binary. 105 SecretBinary string `pulumi:"secretBinary"` 106 SecretId string `pulumi:"secretId"` 107 // Decrypted part of the protected secret information that was originally provided as a string. 108 SecretString string `pulumi:"secretString"` 109 // Unique identifier of this version of the secret. 110 VersionId string `pulumi:"versionId"` 111 VersionStage *string `pulumi:"versionStage"` 112 VersionStages []string `pulumi:"versionStages"` 113 } 114 115 func LookupSecretVersionOutput(ctx *pulumi.Context, args LookupSecretVersionOutputArgs, opts ...pulumi.InvokeOption) LookupSecretVersionResultOutput { 116 return pulumi.ToOutputWithContext(context.Background(), args). 117 ApplyT(func(v interface{}) (LookupSecretVersionResult, error) { 118 args := v.(LookupSecretVersionArgs) 119 r, err := LookupSecretVersion(ctx, &args, opts...) 120 var s LookupSecretVersionResult 121 if r != nil { 122 s = *r 123 } 124 return s, err 125 }).(LookupSecretVersionResultOutput) 126 } 127 128 // A collection of arguments for invoking getSecretVersion. 129 type LookupSecretVersionOutputArgs struct { 130 // Specifies the secret containing the version that you want to retrieve. You can specify either the ARN or the friendly name of the secret. 131 SecretId pulumi.StringInput `pulumi:"secretId"` 132 // Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides `versionStage`. 133 VersionId pulumi.StringPtrInput `pulumi:"versionId"` 134 // Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to `AWSCURRENT`. 135 VersionStage pulumi.StringPtrInput `pulumi:"versionStage"` 136 } 137 138 func (LookupSecretVersionOutputArgs) ElementType() reflect.Type { 139 return reflect.TypeOf((*LookupSecretVersionArgs)(nil)).Elem() 140 } 141 142 // A collection of values returned by getSecretVersion. 143 type LookupSecretVersionResultOutput struct{ *pulumi.OutputState } 144 145 func (LookupSecretVersionResultOutput) ElementType() reflect.Type { 146 return reflect.TypeOf((*LookupSecretVersionResult)(nil)).Elem() 147 } 148 149 func (o LookupSecretVersionResultOutput) ToLookupSecretVersionResultOutput() LookupSecretVersionResultOutput { 150 return o 151 } 152 153 func (o LookupSecretVersionResultOutput) ToLookupSecretVersionResultOutputWithContext(ctx context.Context) LookupSecretVersionResultOutput { 154 return o 155 } 156 157 // ARN of the secret. 158 func (o LookupSecretVersionResultOutput) Arn() pulumi.StringOutput { 159 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.Arn }).(pulumi.StringOutput) 160 } 161 162 // Created date of the secret in UTC. 163 func (o LookupSecretVersionResultOutput) CreatedDate() pulumi.StringOutput { 164 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.CreatedDate }).(pulumi.StringOutput) 165 } 166 167 // The provider-assigned unique ID for this managed resource. 168 func (o LookupSecretVersionResultOutput) Id() pulumi.StringOutput { 169 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.Id }).(pulumi.StringOutput) 170 } 171 172 // Decrypted part of the protected secret information that was originally provided as a binary. 173 func (o LookupSecretVersionResultOutput) SecretBinary() pulumi.StringOutput { 174 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.SecretBinary }).(pulumi.StringOutput) 175 } 176 177 func (o LookupSecretVersionResultOutput) SecretId() pulumi.StringOutput { 178 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.SecretId }).(pulumi.StringOutput) 179 } 180 181 // Decrypted part of the protected secret information that was originally provided as a string. 182 func (o LookupSecretVersionResultOutput) SecretString() pulumi.StringOutput { 183 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.SecretString }).(pulumi.StringOutput) 184 } 185 186 // Unique identifier of this version of the secret. 187 func (o LookupSecretVersionResultOutput) VersionId() pulumi.StringOutput { 188 return o.ApplyT(func(v LookupSecretVersionResult) string { return v.VersionId }).(pulumi.StringOutput) 189 } 190 191 func (o LookupSecretVersionResultOutput) VersionStage() pulumi.StringPtrOutput { 192 return o.ApplyT(func(v LookupSecretVersionResult) *string { return v.VersionStage }).(pulumi.StringPtrOutput) 193 } 194 195 func (o LookupSecretVersionResultOutput) VersionStages() pulumi.StringArrayOutput { 196 return o.ApplyT(func(v LookupSecretVersionResult) []string { return v.VersionStages }).(pulumi.StringArrayOutput) 197 } 198 199 func init() { 200 pulumi.RegisterOutputType(LookupSecretVersionResultOutput{}) 201 }