github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iam/accessKey.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 iam 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides an IAM access key. This is a set of credentials that allow API requests to be made as an IAM user. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 26 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 27 // 28 // ) 29 // 30 // func main() { 31 // pulumi.Run(func(ctx *pulumi.Context) error { 32 // lbUser, err := iam.NewUser(ctx, "lb", &iam.UserArgs{ 33 // Name: pulumi.String("loadbalancer"), 34 // Path: pulumi.String("/system/"), 35 // }) 36 // if err != nil { 37 // return err 38 // } 39 // lb, err := iam.NewAccessKey(ctx, "lb", &iam.AccessKeyArgs{ 40 // User: lbUser.Name, 41 // PgpKey: pulumi.String("keybase:some_person_that_exists"), 42 // }) 43 // if err != nil { 44 // return err 45 // } 46 // lbRo, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ 47 // Statements: []iam.GetPolicyDocumentStatement{ 48 // { 49 // Effect: pulumi.StringRef("Allow"), 50 // Actions: []string{ 51 // "ec2:Describe*", 52 // }, 53 // Resources: []string{ 54 // "*", 55 // }, 56 // }, 57 // }, 58 // }, nil) 59 // if err != nil { 60 // return err 61 // } 62 // _, err = iam.NewUserPolicy(ctx, "lb_ro", &iam.UserPolicyArgs{ 63 // Name: pulumi.String("test"), 64 // User: lbUser.Name, 65 // Policy: pulumi.String(lbRo.Json), 66 // }) 67 // if err != nil { 68 // return err 69 // } 70 // ctx.Export("secret", lb.EncryptedSecret) 71 // return nil 72 // }) 73 // } 74 // 75 // ``` 76 // <!--End PulumiCodeChooser --> 77 // 78 // <!--Start PulumiCodeChooser --> 79 // ```go 80 // package main 81 // 82 // import ( 83 // 84 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 85 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 86 // 87 // ) 88 // 89 // func main() { 90 // pulumi.Run(func(ctx *pulumi.Context) error { 91 // test, err := iam.NewUser(ctx, "test", &iam.UserArgs{ 92 // Name: pulumi.String("test"), 93 // Path: pulumi.String("/test/"), 94 // }) 95 // if err != nil { 96 // return err 97 // } 98 // testAccessKey, err := iam.NewAccessKey(ctx, "test", &iam.AccessKeyArgs{ 99 // User: test.Name, 100 // }) 101 // if err != nil { 102 // return err 103 // } 104 // ctx.Export("awsIamSmtpPasswordV4", testAccessKey.SesSmtpPasswordV4) 105 // return nil 106 // }) 107 // } 108 // 109 // ``` 110 // <!--End PulumiCodeChooser --> 111 // 112 // ## Import 113 // 114 // Using `pulumi import`, import IAM Access Keys using the identifier. For example: 115 // 116 // ```sh 117 // $ pulumi import aws:iam/accessKey:AccessKey example AKIA1234567890 118 // ``` 119 // Resource attributes such as `encrypted_secret`, `key_fingerprint`, `pgp_key`, `secret`, `ses_smtp_password_v4`, and `encrypted_ses_smtp_password_v4` are not available for imported resources as this information cannot be read from the IAM API. 120 type AccessKey struct { 121 pulumi.CustomResourceState 122 123 // Date and time in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8) that the access key was created. 124 CreateDate pulumi.StringOutput `pulumi:"createDate"` 125 // Encrypted secret, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted secret may be decrypted using the command line. 126 EncryptedSecret pulumi.StringOutput `pulumi:"encryptedSecret"` 127 // Encrypted SES SMTP password, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted password may be decrypted using the command line. 128 EncryptedSesSmtpPasswordV4 pulumi.StringOutput `pulumi:"encryptedSesSmtpPasswordV4"` 129 // Fingerprint of the PGP key used to encrypt the secret. This attribute is not available for imported resources. 130 KeyFingerprint pulumi.StringOutput `pulumi:"keyFingerprint"` 131 // Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`). 132 PgpKey pulumi.StringPtrOutput `pulumi:"pgpKey"` 133 // Secret access key. This attribute is not available for imported resources. Note that this will be written to the state file. If you use this, please protect your backend state file judiciously. Alternatively, you may supply a `pgpKey` instead, which will prevent the secret from being stored in plaintext, at the cost of preventing the use of the secret key in automation. 134 Secret pulumi.StringOutput `pulumi:"secret"` 135 // Secret access key converted into an SES SMTP password by applying [AWS's documented Sigv4 conversion algorithm](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert). This attribute is not available for imported resources. As SigV4 is region specific, valid Provider regions are `ap-south-1`, `ap-southeast-2`, `eu-central-1`, `eu-west-1`, `us-east-1` and `us-west-2`. See current [AWS SES regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region). 136 SesSmtpPasswordV4 pulumi.StringOutput `pulumi:"sesSmtpPasswordV4"` 137 // Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`. 138 Status pulumi.StringPtrOutput `pulumi:"status"` 139 // IAM user to associate with this access key. 140 User pulumi.StringOutput `pulumi:"user"` 141 } 142 143 // NewAccessKey registers a new resource with the given unique name, arguments, and options. 144 func NewAccessKey(ctx *pulumi.Context, 145 name string, args *AccessKeyArgs, opts ...pulumi.ResourceOption) (*AccessKey, error) { 146 if args == nil { 147 return nil, errors.New("missing one or more required arguments") 148 } 149 150 if args.User == nil { 151 return nil, errors.New("invalid value for required argument 'User'") 152 } 153 secrets := pulumi.AdditionalSecretOutputs([]string{ 154 "secret", 155 "sesSmtpPasswordV4", 156 }) 157 opts = append(opts, secrets) 158 opts = internal.PkgResourceDefaultOpts(opts) 159 var resource AccessKey 160 err := ctx.RegisterResource("aws:iam/accessKey:AccessKey", name, args, &resource, opts...) 161 if err != nil { 162 return nil, err 163 } 164 return &resource, nil 165 } 166 167 // GetAccessKey gets an existing AccessKey resource's state with the given name, ID, and optional 168 // state properties that are used to uniquely qualify the lookup (nil if not required). 169 func GetAccessKey(ctx *pulumi.Context, 170 name string, id pulumi.IDInput, state *AccessKeyState, opts ...pulumi.ResourceOption) (*AccessKey, error) { 171 var resource AccessKey 172 err := ctx.ReadResource("aws:iam/accessKey:AccessKey", name, id, state, &resource, opts...) 173 if err != nil { 174 return nil, err 175 } 176 return &resource, nil 177 } 178 179 // Input properties used for looking up and filtering AccessKey resources. 180 type accessKeyState struct { 181 // Date and time in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8) that the access key was created. 182 CreateDate *string `pulumi:"createDate"` 183 // Encrypted secret, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted secret may be decrypted using the command line. 184 EncryptedSecret *string `pulumi:"encryptedSecret"` 185 // Encrypted SES SMTP password, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted password may be decrypted using the command line. 186 EncryptedSesSmtpPasswordV4 *string `pulumi:"encryptedSesSmtpPasswordV4"` 187 // Fingerprint of the PGP key used to encrypt the secret. This attribute is not available for imported resources. 188 KeyFingerprint *string `pulumi:"keyFingerprint"` 189 // Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`). 190 PgpKey *string `pulumi:"pgpKey"` 191 // Secret access key. This attribute is not available for imported resources. Note that this will be written to the state file. If you use this, please protect your backend state file judiciously. Alternatively, you may supply a `pgpKey` instead, which will prevent the secret from being stored in plaintext, at the cost of preventing the use of the secret key in automation. 192 Secret *string `pulumi:"secret"` 193 // Secret access key converted into an SES SMTP password by applying [AWS's documented Sigv4 conversion algorithm](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert). This attribute is not available for imported resources. As SigV4 is region specific, valid Provider regions are `ap-south-1`, `ap-southeast-2`, `eu-central-1`, `eu-west-1`, `us-east-1` and `us-west-2`. See current [AWS SES regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region). 194 SesSmtpPasswordV4 *string `pulumi:"sesSmtpPasswordV4"` 195 // Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`. 196 Status *string `pulumi:"status"` 197 // IAM user to associate with this access key. 198 User *string `pulumi:"user"` 199 } 200 201 type AccessKeyState struct { 202 // Date and time in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8) that the access key was created. 203 CreateDate pulumi.StringPtrInput 204 // Encrypted secret, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted secret may be decrypted using the command line. 205 EncryptedSecret pulumi.StringPtrInput 206 // Encrypted SES SMTP password, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted password may be decrypted using the command line. 207 EncryptedSesSmtpPasswordV4 pulumi.StringPtrInput 208 // Fingerprint of the PGP key used to encrypt the secret. This attribute is not available for imported resources. 209 KeyFingerprint pulumi.StringPtrInput 210 // Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`). 211 PgpKey pulumi.StringPtrInput 212 // Secret access key. This attribute is not available for imported resources. Note that this will be written to the state file. If you use this, please protect your backend state file judiciously. Alternatively, you may supply a `pgpKey` instead, which will prevent the secret from being stored in plaintext, at the cost of preventing the use of the secret key in automation. 213 Secret pulumi.StringPtrInput 214 // Secret access key converted into an SES SMTP password by applying [AWS's documented Sigv4 conversion algorithm](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert). This attribute is not available for imported resources. As SigV4 is region specific, valid Provider regions are `ap-south-1`, `ap-southeast-2`, `eu-central-1`, `eu-west-1`, `us-east-1` and `us-west-2`. See current [AWS SES regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region). 215 SesSmtpPasswordV4 pulumi.StringPtrInput 216 // Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`. 217 Status pulumi.StringPtrInput 218 // IAM user to associate with this access key. 219 User pulumi.StringPtrInput 220 } 221 222 func (AccessKeyState) ElementType() reflect.Type { 223 return reflect.TypeOf((*accessKeyState)(nil)).Elem() 224 } 225 226 type accessKeyArgs struct { 227 // Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`). 228 PgpKey *string `pulumi:"pgpKey"` 229 // Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`. 230 Status *string `pulumi:"status"` 231 // IAM user to associate with this access key. 232 User string `pulumi:"user"` 233 } 234 235 // The set of arguments for constructing a AccessKey resource. 236 type AccessKeyArgs struct { 237 // Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`). 238 PgpKey pulumi.StringPtrInput 239 // Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`. 240 Status pulumi.StringPtrInput 241 // IAM user to associate with this access key. 242 User pulumi.StringInput 243 } 244 245 func (AccessKeyArgs) ElementType() reflect.Type { 246 return reflect.TypeOf((*accessKeyArgs)(nil)).Elem() 247 } 248 249 type AccessKeyInput interface { 250 pulumi.Input 251 252 ToAccessKeyOutput() AccessKeyOutput 253 ToAccessKeyOutputWithContext(ctx context.Context) AccessKeyOutput 254 } 255 256 func (*AccessKey) ElementType() reflect.Type { 257 return reflect.TypeOf((**AccessKey)(nil)).Elem() 258 } 259 260 func (i *AccessKey) ToAccessKeyOutput() AccessKeyOutput { 261 return i.ToAccessKeyOutputWithContext(context.Background()) 262 } 263 264 func (i *AccessKey) ToAccessKeyOutputWithContext(ctx context.Context) AccessKeyOutput { 265 return pulumi.ToOutputWithContext(ctx, i).(AccessKeyOutput) 266 } 267 268 // AccessKeyArrayInput is an input type that accepts AccessKeyArray and AccessKeyArrayOutput values. 269 // You can construct a concrete instance of `AccessKeyArrayInput` via: 270 // 271 // AccessKeyArray{ AccessKeyArgs{...} } 272 type AccessKeyArrayInput interface { 273 pulumi.Input 274 275 ToAccessKeyArrayOutput() AccessKeyArrayOutput 276 ToAccessKeyArrayOutputWithContext(context.Context) AccessKeyArrayOutput 277 } 278 279 type AccessKeyArray []AccessKeyInput 280 281 func (AccessKeyArray) ElementType() reflect.Type { 282 return reflect.TypeOf((*[]*AccessKey)(nil)).Elem() 283 } 284 285 func (i AccessKeyArray) ToAccessKeyArrayOutput() AccessKeyArrayOutput { 286 return i.ToAccessKeyArrayOutputWithContext(context.Background()) 287 } 288 289 func (i AccessKeyArray) ToAccessKeyArrayOutputWithContext(ctx context.Context) AccessKeyArrayOutput { 290 return pulumi.ToOutputWithContext(ctx, i).(AccessKeyArrayOutput) 291 } 292 293 // AccessKeyMapInput is an input type that accepts AccessKeyMap and AccessKeyMapOutput values. 294 // You can construct a concrete instance of `AccessKeyMapInput` via: 295 // 296 // AccessKeyMap{ "key": AccessKeyArgs{...} } 297 type AccessKeyMapInput interface { 298 pulumi.Input 299 300 ToAccessKeyMapOutput() AccessKeyMapOutput 301 ToAccessKeyMapOutputWithContext(context.Context) AccessKeyMapOutput 302 } 303 304 type AccessKeyMap map[string]AccessKeyInput 305 306 func (AccessKeyMap) ElementType() reflect.Type { 307 return reflect.TypeOf((*map[string]*AccessKey)(nil)).Elem() 308 } 309 310 func (i AccessKeyMap) ToAccessKeyMapOutput() AccessKeyMapOutput { 311 return i.ToAccessKeyMapOutputWithContext(context.Background()) 312 } 313 314 func (i AccessKeyMap) ToAccessKeyMapOutputWithContext(ctx context.Context) AccessKeyMapOutput { 315 return pulumi.ToOutputWithContext(ctx, i).(AccessKeyMapOutput) 316 } 317 318 type AccessKeyOutput struct{ *pulumi.OutputState } 319 320 func (AccessKeyOutput) ElementType() reflect.Type { 321 return reflect.TypeOf((**AccessKey)(nil)).Elem() 322 } 323 324 func (o AccessKeyOutput) ToAccessKeyOutput() AccessKeyOutput { 325 return o 326 } 327 328 func (o AccessKeyOutput) ToAccessKeyOutputWithContext(ctx context.Context) AccessKeyOutput { 329 return o 330 } 331 332 // Date and time in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8) that the access key was created. 333 func (o AccessKeyOutput) CreateDate() pulumi.StringOutput { 334 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.CreateDate }).(pulumi.StringOutput) 335 } 336 337 // Encrypted secret, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted secret may be decrypted using the command line. 338 func (o AccessKeyOutput) EncryptedSecret() pulumi.StringOutput { 339 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.EncryptedSecret }).(pulumi.StringOutput) 340 } 341 342 // Encrypted SES SMTP password, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted password may be decrypted using the command line. 343 func (o AccessKeyOutput) EncryptedSesSmtpPasswordV4() pulumi.StringOutput { 344 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.EncryptedSesSmtpPasswordV4 }).(pulumi.StringOutput) 345 } 346 347 // Fingerprint of the PGP key used to encrypt the secret. This attribute is not available for imported resources. 348 func (o AccessKeyOutput) KeyFingerprint() pulumi.StringOutput { 349 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.KeyFingerprint }).(pulumi.StringOutput) 350 } 351 352 // Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`). 353 func (o AccessKeyOutput) PgpKey() pulumi.StringPtrOutput { 354 return o.ApplyT(func(v *AccessKey) pulumi.StringPtrOutput { return v.PgpKey }).(pulumi.StringPtrOutput) 355 } 356 357 // Secret access key. This attribute is not available for imported resources. Note that this will be written to the state file. If you use this, please protect your backend state file judiciously. Alternatively, you may supply a `pgpKey` instead, which will prevent the secret from being stored in plaintext, at the cost of preventing the use of the secret key in automation. 358 func (o AccessKeyOutput) Secret() pulumi.StringOutput { 359 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.Secret }).(pulumi.StringOutput) 360 } 361 362 // Secret access key converted into an SES SMTP password by applying [AWS's documented Sigv4 conversion algorithm](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert). This attribute is not available for imported resources. As SigV4 is region specific, valid Provider regions are `ap-south-1`, `ap-southeast-2`, `eu-central-1`, `eu-west-1`, `us-east-1` and `us-west-2`. See current [AWS SES regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region). 363 func (o AccessKeyOutput) SesSmtpPasswordV4() pulumi.StringOutput { 364 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.SesSmtpPasswordV4 }).(pulumi.StringOutput) 365 } 366 367 // Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`. 368 func (o AccessKeyOutput) Status() pulumi.StringPtrOutput { 369 return o.ApplyT(func(v *AccessKey) pulumi.StringPtrOutput { return v.Status }).(pulumi.StringPtrOutput) 370 } 371 372 // IAM user to associate with this access key. 373 func (o AccessKeyOutput) User() pulumi.StringOutput { 374 return o.ApplyT(func(v *AccessKey) pulumi.StringOutput { return v.User }).(pulumi.StringOutput) 375 } 376 377 type AccessKeyArrayOutput struct{ *pulumi.OutputState } 378 379 func (AccessKeyArrayOutput) ElementType() reflect.Type { 380 return reflect.TypeOf((*[]*AccessKey)(nil)).Elem() 381 } 382 383 func (o AccessKeyArrayOutput) ToAccessKeyArrayOutput() AccessKeyArrayOutput { 384 return o 385 } 386 387 func (o AccessKeyArrayOutput) ToAccessKeyArrayOutputWithContext(ctx context.Context) AccessKeyArrayOutput { 388 return o 389 } 390 391 func (o AccessKeyArrayOutput) Index(i pulumi.IntInput) AccessKeyOutput { 392 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *AccessKey { 393 return vs[0].([]*AccessKey)[vs[1].(int)] 394 }).(AccessKeyOutput) 395 } 396 397 type AccessKeyMapOutput struct{ *pulumi.OutputState } 398 399 func (AccessKeyMapOutput) ElementType() reflect.Type { 400 return reflect.TypeOf((*map[string]*AccessKey)(nil)).Elem() 401 } 402 403 func (o AccessKeyMapOutput) ToAccessKeyMapOutput() AccessKeyMapOutput { 404 return o 405 } 406 407 func (o AccessKeyMapOutput) ToAccessKeyMapOutputWithContext(ctx context.Context) AccessKeyMapOutput { 408 return o 409 } 410 411 func (o AccessKeyMapOutput) MapIndex(k pulumi.StringInput) AccessKeyOutput { 412 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *AccessKey { 413 return vs[0].(map[string]*AccessKey)[vs[1].(string)] 414 }).(AccessKeyOutput) 415 } 416 417 func init() { 418 pulumi.RegisterInputType(reflect.TypeOf((*AccessKeyInput)(nil)).Elem(), &AccessKey{}) 419 pulumi.RegisterInputType(reflect.TypeOf((*AccessKeyArrayInput)(nil)).Elem(), AccessKeyArray{}) 420 pulumi.RegisterInputType(reflect.TypeOf((*AccessKeyMapInput)(nil)).Elem(), AccessKeyMap{}) 421 pulumi.RegisterOutputType(AccessKeyOutput{}) 422 pulumi.RegisterOutputType(AccessKeyArrayOutput{}) 423 pulumi.RegisterOutputType(AccessKeyMapOutput{}) 424 }