github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/secretsmanager/secret.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 // Provides a resource to manage AWS Secrets Manager secret metadata. To manage secret rotation, see the `secretsmanager.SecretRotation` resource. To manage a secret value, see the `secretsmanager.SecretVersion` resource. 15 // 16 // ## Example Usage 17 // 18 // ### Basic 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/secretsmanager" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // _, err := secretsmanager.NewSecret(ctx, "example", &secretsmanager.SecretArgs{ 34 // Name: pulumi.String("example"), 35 // }) 36 // if err != nil { 37 // return err 38 // } 39 // return nil 40 // }) 41 // } 42 // 43 // ``` 44 // <!--End PulumiCodeChooser --> 45 // 46 // ## Import 47 // 48 // Using `pulumi import`, import `aws_secretsmanager_secret` using the secret Amazon Resource Name (ARN). For example: 49 // 50 // ```sh 51 // $ pulumi import aws:secretsmanager/secret:Secret example arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456 52 // ``` 53 type Secret struct { 54 pulumi.CustomResourceState 55 56 // ARN of the secret. 57 Arn pulumi.StringOutput `pulumi:"arn"` 58 // Description of the secret. 59 Description pulumi.StringPtrOutput `pulumi:"description"` 60 // Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. 61 ForceOverwriteReplicaSecret pulumi.BoolPtrOutput `pulumi:"forceOverwriteReplicaSecret"` 62 // ARN or Id of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. 63 KmsKeyId pulumi.StringPtrOutput `pulumi:"kmsKeyId"` 64 // Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `namePrefix`. 65 Name pulumi.StringOutput `pulumi:"name"` 66 // Creates a unique name beginning with the specified prefix. Conflicts with `name`. 67 NamePrefix pulumi.StringOutput `pulumi:"namePrefix"` 68 // Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `secretsmanager.SecretPolicy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). 69 Policy pulumi.StringOutput `pulumi:"policy"` 70 // Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. 71 RecoveryWindowInDays pulumi.IntPtrOutput `pulumi:"recoveryWindowInDays"` 72 // Configuration block to support secret replication. See details below. 73 Replicas SecretReplicaArrayOutput `pulumi:"replicas"` 74 // Key-value map of user-defined tags that are attached to the secret. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 75 Tags pulumi.StringMapOutput `pulumi:"tags"` 76 // Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 77 // 78 // Deprecated: Please use `tags` instead. 79 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 80 } 81 82 // NewSecret registers a new resource with the given unique name, arguments, and options. 83 func NewSecret(ctx *pulumi.Context, 84 name string, args *SecretArgs, opts ...pulumi.ResourceOption) (*Secret, error) { 85 if args == nil { 86 args = &SecretArgs{} 87 } 88 89 opts = internal.PkgResourceDefaultOpts(opts) 90 var resource Secret 91 err := ctx.RegisterResource("aws:secretsmanager/secret:Secret", name, args, &resource, opts...) 92 if err != nil { 93 return nil, err 94 } 95 return &resource, nil 96 } 97 98 // GetSecret gets an existing Secret resource's state with the given name, ID, and optional 99 // state properties that are used to uniquely qualify the lookup (nil if not required). 100 func GetSecret(ctx *pulumi.Context, 101 name string, id pulumi.IDInput, state *SecretState, opts ...pulumi.ResourceOption) (*Secret, error) { 102 var resource Secret 103 err := ctx.ReadResource("aws:secretsmanager/secret:Secret", name, id, state, &resource, opts...) 104 if err != nil { 105 return nil, err 106 } 107 return &resource, nil 108 } 109 110 // Input properties used for looking up and filtering Secret resources. 111 type secretState struct { 112 // ARN of the secret. 113 Arn *string `pulumi:"arn"` 114 // Description of the secret. 115 Description *string `pulumi:"description"` 116 // Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. 117 ForceOverwriteReplicaSecret *bool `pulumi:"forceOverwriteReplicaSecret"` 118 // ARN or Id of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. 119 KmsKeyId *string `pulumi:"kmsKeyId"` 120 // Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `namePrefix`. 121 Name *string `pulumi:"name"` 122 // Creates a unique name beginning with the specified prefix. Conflicts with `name`. 123 NamePrefix *string `pulumi:"namePrefix"` 124 // Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `secretsmanager.SecretPolicy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). 125 Policy *string `pulumi:"policy"` 126 // Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. 127 RecoveryWindowInDays *int `pulumi:"recoveryWindowInDays"` 128 // Configuration block to support secret replication. See details below. 129 Replicas []SecretReplica `pulumi:"replicas"` 130 // Key-value map of user-defined tags that are attached to the secret. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 131 Tags map[string]string `pulumi:"tags"` 132 // Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 133 // 134 // Deprecated: Please use `tags` instead. 135 TagsAll map[string]string `pulumi:"tagsAll"` 136 } 137 138 type SecretState struct { 139 // ARN of the secret. 140 Arn pulumi.StringPtrInput 141 // Description of the secret. 142 Description pulumi.StringPtrInput 143 // Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. 144 ForceOverwriteReplicaSecret pulumi.BoolPtrInput 145 // ARN or Id of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. 146 KmsKeyId pulumi.StringPtrInput 147 // Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `namePrefix`. 148 Name pulumi.StringPtrInput 149 // Creates a unique name beginning with the specified prefix. Conflicts with `name`. 150 NamePrefix pulumi.StringPtrInput 151 // Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `secretsmanager.SecretPolicy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). 152 Policy pulumi.StringPtrInput 153 // Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. 154 RecoveryWindowInDays pulumi.IntPtrInput 155 // Configuration block to support secret replication. See details below. 156 Replicas SecretReplicaArrayInput 157 // Key-value map of user-defined tags that are attached to the secret. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 158 Tags pulumi.StringMapInput 159 // Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 160 // 161 // Deprecated: Please use `tags` instead. 162 TagsAll pulumi.StringMapInput 163 } 164 165 func (SecretState) ElementType() reflect.Type { 166 return reflect.TypeOf((*secretState)(nil)).Elem() 167 } 168 169 type secretArgs struct { 170 // Description of the secret. 171 Description *string `pulumi:"description"` 172 // Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. 173 ForceOverwriteReplicaSecret *bool `pulumi:"forceOverwriteReplicaSecret"` 174 // ARN or Id of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. 175 KmsKeyId *string `pulumi:"kmsKeyId"` 176 // Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `namePrefix`. 177 Name *string `pulumi:"name"` 178 // Creates a unique name beginning with the specified prefix. Conflicts with `name`. 179 NamePrefix *string `pulumi:"namePrefix"` 180 // Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `secretsmanager.SecretPolicy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). 181 Policy *string `pulumi:"policy"` 182 // Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. 183 RecoveryWindowInDays *int `pulumi:"recoveryWindowInDays"` 184 // Configuration block to support secret replication. See details below. 185 Replicas []SecretReplica `pulumi:"replicas"` 186 // Key-value map of user-defined tags that are attached to the secret. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 187 Tags map[string]string `pulumi:"tags"` 188 } 189 190 // The set of arguments for constructing a Secret resource. 191 type SecretArgs struct { 192 // Description of the secret. 193 Description pulumi.StringPtrInput 194 // Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. 195 ForceOverwriteReplicaSecret pulumi.BoolPtrInput 196 // ARN or Id of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. 197 KmsKeyId pulumi.StringPtrInput 198 // Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `namePrefix`. 199 Name pulumi.StringPtrInput 200 // Creates a unique name beginning with the specified prefix. Conflicts with `name`. 201 NamePrefix pulumi.StringPtrInput 202 // Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `secretsmanager.SecretPolicy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). 203 Policy pulumi.StringPtrInput 204 // Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. 205 RecoveryWindowInDays pulumi.IntPtrInput 206 // Configuration block to support secret replication. See details below. 207 Replicas SecretReplicaArrayInput 208 // Key-value map of user-defined tags that are attached to the secret. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 209 Tags pulumi.StringMapInput 210 } 211 212 func (SecretArgs) ElementType() reflect.Type { 213 return reflect.TypeOf((*secretArgs)(nil)).Elem() 214 } 215 216 type SecretInput interface { 217 pulumi.Input 218 219 ToSecretOutput() SecretOutput 220 ToSecretOutputWithContext(ctx context.Context) SecretOutput 221 } 222 223 func (*Secret) ElementType() reflect.Type { 224 return reflect.TypeOf((**Secret)(nil)).Elem() 225 } 226 227 func (i *Secret) ToSecretOutput() SecretOutput { 228 return i.ToSecretOutputWithContext(context.Background()) 229 } 230 231 func (i *Secret) ToSecretOutputWithContext(ctx context.Context) SecretOutput { 232 return pulumi.ToOutputWithContext(ctx, i).(SecretOutput) 233 } 234 235 // SecretArrayInput is an input type that accepts SecretArray and SecretArrayOutput values. 236 // You can construct a concrete instance of `SecretArrayInput` via: 237 // 238 // SecretArray{ SecretArgs{...} } 239 type SecretArrayInput interface { 240 pulumi.Input 241 242 ToSecretArrayOutput() SecretArrayOutput 243 ToSecretArrayOutputWithContext(context.Context) SecretArrayOutput 244 } 245 246 type SecretArray []SecretInput 247 248 func (SecretArray) ElementType() reflect.Type { 249 return reflect.TypeOf((*[]*Secret)(nil)).Elem() 250 } 251 252 func (i SecretArray) ToSecretArrayOutput() SecretArrayOutput { 253 return i.ToSecretArrayOutputWithContext(context.Background()) 254 } 255 256 func (i SecretArray) ToSecretArrayOutputWithContext(ctx context.Context) SecretArrayOutput { 257 return pulumi.ToOutputWithContext(ctx, i).(SecretArrayOutput) 258 } 259 260 // SecretMapInput is an input type that accepts SecretMap and SecretMapOutput values. 261 // You can construct a concrete instance of `SecretMapInput` via: 262 // 263 // SecretMap{ "key": SecretArgs{...} } 264 type SecretMapInput interface { 265 pulumi.Input 266 267 ToSecretMapOutput() SecretMapOutput 268 ToSecretMapOutputWithContext(context.Context) SecretMapOutput 269 } 270 271 type SecretMap map[string]SecretInput 272 273 func (SecretMap) ElementType() reflect.Type { 274 return reflect.TypeOf((*map[string]*Secret)(nil)).Elem() 275 } 276 277 func (i SecretMap) ToSecretMapOutput() SecretMapOutput { 278 return i.ToSecretMapOutputWithContext(context.Background()) 279 } 280 281 func (i SecretMap) ToSecretMapOutputWithContext(ctx context.Context) SecretMapOutput { 282 return pulumi.ToOutputWithContext(ctx, i).(SecretMapOutput) 283 } 284 285 type SecretOutput struct{ *pulumi.OutputState } 286 287 func (SecretOutput) ElementType() reflect.Type { 288 return reflect.TypeOf((**Secret)(nil)).Elem() 289 } 290 291 func (o SecretOutput) ToSecretOutput() SecretOutput { 292 return o 293 } 294 295 func (o SecretOutput) ToSecretOutputWithContext(ctx context.Context) SecretOutput { 296 return o 297 } 298 299 // ARN of the secret. 300 func (o SecretOutput) Arn() pulumi.StringOutput { 301 return o.ApplyT(func(v *Secret) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 302 } 303 304 // Description of the secret. 305 func (o SecretOutput) Description() pulumi.StringPtrOutput { 306 return o.ApplyT(func(v *Secret) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput) 307 } 308 309 // Accepts boolean value to specify whether to overwrite a secret with the same name in the destination Region. 310 func (o SecretOutput) ForceOverwriteReplicaSecret() pulumi.BoolPtrOutput { 311 return o.ApplyT(func(v *Secret) pulumi.BoolPtrOutput { return v.ForceOverwriteReplicaSecret }).(pulumi.BoolPtrOutput) 312 } 313 314 // ARN or Id of the AWS KMS key to be used to encrypt the secret values in the versions stored in this secret. If you need to reference a CMK in a different account, you can use only the key ARN. If you don't specify this value, then Secrets Manager defaults to using the AWS account's default KMS key (the one named `aws/secretsmanager`). If the default KMS key with that name doesn't yet exist, then AWS Secrets Manager creates it for you automatically the first time. 315 func (o SecretOutput) KmsKeyId() pulumi.StringPtrOutput { 316 return o.ApplyT(func(v *Secret) pulumi.StringPtrOutput { return v.KmsKeyId }).(pulumi.StringPtrOutput) 317 } 318 319 // Friendly name of the new secret. The secret name can consist of uppercase letters, lowercase letters, digits, and any of the following characters: `/_+=.@-` Conflicts with `namePrefix`. 320 func (o SecretOutput) Name() pulumi.StringOutput { 321 return o.ApplyT(func(v *Secret) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 322 } 323 324 // Creates a unique name beginning with the specified prefix. Conflicts with `name`. 325 func (o SecretOutput) NamePrefix() pulumi.StringOutput { 326 return o.ApplyT(func(v *Secret) pulumi.StringOutput { return v.NamePrefix }).(pulumi.StringOutput) 327 } 328 329 // Valid JSON document representing a [resource policy](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-based-policies.html). Removing `policy` from your configuration or setting `policy` to null or an empty string (i.e., `policy = ""`) _will not_ delete the policy since it could have been set by `secretsmanager.SecretPolicy`. To delete the `policy`, set it to `"{}"` (an empty JSON document). 330 func (o SecretOutput) Policy() pulumi.StringOutput { 331 return o.ApplyT(func(v *Secret) pulumi.StringOutput { return v.Policy }).(pulumi.StringOutput) 332 } 333 334 // Number of days that AWS Secrets Manager waits before it can delete the secret. This value can be `0` to force deletion without recovery or range from `7` to `30` days. The default value is `30`. 335 func (o SecretOutput) RecoveryWindowInDays() pulumi.IntPtrOutput { 336 return o.ApplyT(func(v *Secret) pulumi.IntPtrOutput { return v.RecoveryWindowInDays }).(pulumi.IntPtrOutput) 337 } 338 339 // Configuration block to support secret replication. See details below. 340 func (o SecretOutput) Replicas() SecretReplicaArrayOutput { 341 return o.ApplyT(func(v *Secret) SecretReplicaArrayOutput { return v.Replicas }).(SecretReplicaArrayOutput) 342 } 343 344 // Key-value map of user-defined tags that are attached to the secret. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 345 func (o SecretOutput) Tags() pulumi.StringMapOutput { 346 return o.ApplyT(func(v *Secret) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 347 } 348 349 // Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 350 // 351 // Deprecated: Please use `tags` instead. 352 func (o SecretOutput) TagsAll() pulumi.StringMapOutput { 353 return o.ApplyT(func(v *Secret) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 354 } 355 356 type SecretArrayOutput struct{ *pulumi.OutputState } 357 358 func (SecretArrayOutput) ElementType() reflect.Type { 359 return reflect.TypeOf((*[]*Secret)(nil)).Elem() 360 } 361 362 func (o SecretArrayOutput) ToSecretArrayOutput() SecretArrayOutput { 363 return o 364 } 365 366 func (o SecretArrayOutput) ToSecretArrayOutputWithContext(ctx context.Context) SecretArrayOutput { 367 return o 368 } 369 370 func (o SecretArrayOutput) Index(i pulumi.IntInput) SecretOutput { 371 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Secret { 372 return vs[0].([]*Secret)[vs[1].(int)] 373 }).(SecretOutput) 374 } 375 376 type SecretMapOutput struct{ *pulumi.OutputState } 377 378 func (SecretMapOutput) ElementType() reflect.Type { 379 return reflect.TypeOf((*map[string]*Secret)(nil)).Elem() 380 } 381 382 func (o SecretMapOutput) ToSecretMapOutput() SecretMapOutput { 383 return o 384 } 385 386 func (o SecretMapOutput) ToSecretMapOutputWithContext(ctx context.Context) SecretMapOutput { 387 return o 388 } 389 390 func (o SecretMapOutput) MapIndex(k pulumi.StringInput) SecretOutput { 391 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Secret { 392 return vs[0].(map[string]*Secret)[vs[1].(string)] 393 }).(SecretOutput) 394 } 395 396 func init() { 397 pulumi.RegisterInputType(reflect.TypeOf((*SecretInput)(nil)).Elem(), &Secret{}) 398 pulumi.RegisterInputType(reflect.TypeOf((*SecretArrayInput)(nil)).Elem(), SecretArray{}) 399 pulumi.RegisterInputType(reflect.TypeOf((*SecretMapInput)(nil)).Elem(), SecretMap{}) 400 pulumi.RegisterOutputType(SecretOutput{}) 401 pulumi.RegisterOutputType(SecretArrayOutput{}) 402 pulumi.RegisterOutputType(SecretMapOutput{}) 403 }