github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iam/sshKey.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 // Uploads an SSH public key and associates it with the specified 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 // user, err := iam.NewUser(ctx, "user", &iam.UserArgs{ 33 // Name: pulumi.String("test-user"), 34 // Path: pulumi.String("/"), 35 // }) 36 // if err != nil { 37 // return err 38 // } 39 // _, err = iam.NewSshKey(ctx, "user", &iam.SshKeyArgs{ 40 // Username: user.Name, 41 // Encoding: pulumi.String("SSH"), 42 // PublicKey: pulumi.String("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 mytest@mydomain.com"), 43 // }) 44 // if err != nil { 45 // return err 46 // } 47 // return nil 48 // }) 49 // } 50 // 51 // ``` 52 // <!--End PulumiCodeChooser --> 53 // 54 // ## Import 55 // 56 // Using `pulumi import`, import SSH public keys using the `username`, `ssh_public_key_id`, and `encoding`. For example: 57 // 58 // ```sh 59 // $ pulumi import aws:iam/sshKey:SshKey user user:APKAJNCNNJICVN7CFKCA:SSH 60 // ``` 61 type SshKey struct { 62 pulumi.CustomResourceState 63 64 // Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use `SSH`. To retrieve the public key in PEM format, use `PEM`. 65 Encoding pulumi.StringOutput `pulumi:"encoding"` 66 // The MD5 message digest of the SSH public key. 67 Fingerprint pulumi.StringOutput `pulumi:"fingerprint"` 68 // The SSH public key. The public key must be encoded in ssh-rsa format or PEM format. 69 PublicKey pulumi.StringOutput `pulumi:"publicKey"` 70 // The unique identifier for the SSH public key. 71 SshPublicKeyId pulumi.StringOutput `pulumi:"sshPublicKeyId"` 72 // The status to assign to the SSH public key. Active means the key can be used for authentication with an AWS CodeCommit repository. Inactive means the key cannot be used. Default is `active`. 73 Status pulumi.StringOutput `pulumi:"status"` 74 // The name of the IAM user to associate the SSH public key with. 75 Username pulumi.StringOutput `pulumi:"username"` 76 } 77 78 // NewSshKey registers a new resource with the given unique name, arguments, and options. 79 func NewSshKey(ctx *pulumi.Context, 80 name string, args *SshKeyArgs, opts ...pulumi.ResourceOption) (*SshKey, error) { 81 if args == nil { 82 return nil, errors.New("missing one or more required arguments") 83 } 84 85 if args.Encoding == nil { 86 return nil, errors.New("invalid value for required argument 'Encoding'") 87 } 88 if args.PublicKey == nil { 89 return nil, errors.New("invalid value for required argument 'PublicKey'") 90 } 91 if args.Username == nil { 92 return nil, errors.New("invalid value for required argument 'Username'") 93 } 94 opts = internal.PkgResourceDefaultOpts(opts) 95 var resource SshKey 96 err := ctx.RegisterResource("aws:iam/sshKey:SshKey", name, args, &resource, opts...) 97 if err != nil { 98 return nil, err 99 } 100 return &resource, nil 101 } 102 103 // GetSshKey gets an existing SshKey resource's state with the given name, ID, and optional 104 // state properties that are used to uniquely qualify the lookup (nil if not required). 105 func GetSshKey(ctx *pulumi.Context, 106 name string, id pulumi.IDInput, state *SshKeyState, opts ...pulumi.ResourceOption) (*SshKey, error) { 107 var resource SshKey 108 err := ctx.ReadResource("aws:iam/sshKey:SshKey", name, id, state, &resource, opts...) 109 if err != nil { 110 return nil, err 111 } 112 return &resource, nil 113 } 114 115 // Input properties used for looking up and filtering SshKey resources. 116 type sshKeyState struct { 117 // Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use `SSH`. To retrieve the public key in PEM format, use `PEM`. 118 Encoding *string `pulumi:"encoding"` 119 // The MD5 message digest of the SSH public key. 120 Fingerprint *string `pulumi:"fingerprint"` 121 // The SSH public key. The public key must be encoded in ssh-rsa format or PEM format. 122 PublicKey *string `pulumi:"publicKey"` 123 // The unique identifier for the SSH public key. 124 SshPublicKeyId *string `pulumi:"sshPublicKeyId"` 125 // The status to assign to the SSH public key. Active means the key can be used for authentication with an AWS CodeCommit repository. Inactive means the key cannot be used. Default is `active`. 126 Status *string `pulumi:"status"` 127 // The name of the IAM user to associate the SSH public key with. 128 Username *string `pulumi:"username"` 129 } 130 131 type SshKeyState struct { 132 // Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use `SSH`. To retrieve the public key in PEM format, use `PEM`. 133 Encoding pulumi.StringPtrInput 134 // The MD5 message digest of the SSH public key. 135 Fingerprint pulumi.StringPtrInput 136 // The SSH public key. The public key must be encoded in ssh-rsa format or PEM format. 137 PublicKey pulumi.StringPtrInput 138 // The unique identifier for the SSH public key. 139 SshPublicKeyId pulumi.StringPtrInput 140 // The status to assign to the SSH public key. Active means the key can be used for authentication with an AWS CodeCommit repository. Inactive means the key cannot be used. Default is `active`. 141 Status pulumi.StringPtrInput 142 // The name of the IAM user to associate the SSH public key with. 143 Username pulumi.StringPtrInput 144 } 145 146 func (SshKeyState) ElementType() reflect.Type { 147 return reflect.TypeOf((*sshKeyState)(nil)).Elem() 148 } 149 150 type sshKeyArgs struct { 151 // Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use `SSH`. To retrieve the public key in PEM format, use `PEM`. 152 Encoding string `pulumi:"encoding"` 153 // The SSH public key. The public key must be encoded in ssh-rsa format or PEM format. 154 PublicKey string `pulumi:"publicKey"` 155 // The status to assign to the SSH public key. Active means the key can be used for authentication with an AWS CodeCommit repository. Inactive means the key cannot be used. Default is `active`. 156 Status *string `pulumi:"status"` 157 // The name of the IAM user to associate the SSH public key with. 158 Username string `pulumi:"username"` 159 } 160 161 // The set of arguments for constructing a SshKey resource. 162 type SshKeyArgs struct { 163 // Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use `SSH`. To retrieve the public key in PEM format, use `PEM`. 164 Encoding pulumi.StringInput 165 // The SSH public key. The public key must be encoded in ssh-rsa format or PEM format. 166 PublicKey pulumi.StringInput 167 // The status to assign to the SSH public key. Active means the key can be used for authentication with an AWS CodeCommit repository. Inactive means the key cannot be used. Default is `active`. 168 Status pulumi.StringPtrInput 169 // The name of the IAM user to associate the SSH public key with. 170 Username pulumi.StringInput 171 } 172 173 func (SshKeyArgs) ElementType() reflect.Type { 174 return reflect.TypeOf((*sshKeyArgs)(nil)).Elem() 175 } 176 177 type SshKeyInput interface { 178 pulumi.Input 179 180 ToSshKeyOutput() SshKeyOutput 181 ToSshKeyOutputWithContext(ctx context.Context) SshKeyOutput 182 } 183 184 func (*SshKey) ElementType() reflect.Type { 185 return reflect.TypeOf((**SshKey)(nil)).Elem() 186 } 187 188 func (i *SshKey) ToSshKeyOutput() SshKeyOutput { 189 return i.ToSshKeyOutputWithContext(context.Background()) 190 } 191 192 func (i *SshKey) ToSshKeyOutputWithContext(ctx context.Context) SshKeyOutput { 193 return pulumi.ToOutputWithContext(ctx, i).(SshKeyOutput) 194 } 195 196 // SshKeyArrayInput is an input type that accepts SshKeyArray and SshKeyArrayOutput values. 197 // You can construct a concrete instance of `SshKeyArrayInput` via: 198 // 199 // SshKeyArray{ SshKeyArgs{...} } 200 type SshKeyArrayInput interface { 201 pulumi.Input 202 203 ToSshKeyArrayOutput() SshKeyArrayOutput 204 ToSshKeyArrayOutputWithContext(context.Context) SshKeyArrayOutput 205 } 206 207 type SshKeyArray []SshKeyInput 208 209 func (SshKeyArray) ElementType() reflect.Type { 210 return reflect.TypeOf((*[]*SshKey)(nil)).Elem() 211 } 212 213 func (i SshKeyArray) ToSshKeyArrayOutput() SshKeyArrayOutput { 214 return i.ToSshKeyArrayOutputWithContext(context.Background()) 215 } 216 217 func (i SshKeyArray) ToSshKeyArrayOutputWithContext(ctx context.Context) SshKeyArrayOutput { 218 return pulumi.ToOutputWithContext(ctx, i).(SshKeyArrayOutput) 219 } 220 221 // SshKeyMapInput is an input type that accepts SshKeyMap and SshKeyMapOutput values. 222 // You can construct a concrete instance of `SshKeyMapInput` via: 223 // 224 // SshKeyMap{ "key": SshKeyArgs{...} } 225 type SshKeyMapInput interface { 226 pulumi.Input 227 228 ToSshKeyMapOutput() SshKeyMapOutput 229 ToSshKeyMapOutputWithContext(context.Context) SshKeyMapOutput 230 } 231 232 type SshKeyMap map[string]SshKeyInput 233 234 func (SshKeyMap) ElementType() reflect.Type { 235 return reflect.TypeOf((*map[string]*SshKey)(nil)).Elem() 236 } 237 238 func (i SshKeyMap) ToSshKeyMapOutput() SshKeyMapOutput { 239 return i.ToSshKeyMapOutputWithContext(context.Background()) 240 } 241 242 func (i SshKeyMap) ToSshKeyMapOutputWithContext(ctx context.Context) SshKeyMapOutput { 243 return pulumi.ToOutputWithContext(ctx, i).(SshKeyMapOutput) 244 } 245 246 type SshKeyOutput struct{ *pulumi.OutputState } 247 248 func (SshKeyOutput) ElementType() reflect.Type { 249 return reflect.TypeOf((**SshKey)(nil)).Elem() 250 } 251 252 func (o SshKeyOutput) ToSshKeyOutput() SshKeyOutput { 253 return o 254 } 255 256 func (o SshKeyOutput) ToSshKeyOutputWithContext(ctx context.Context) SshKeyOutput { 257 return o 258 } 259 260 // Specifies the public key encoding format to use in the response. To retrieve the public key in ssh-rsa format, use `SSH`. To retrieve the public key in PEM format, use `PEM`. 261 func (o SshKeyOutput) Encoding() pulumi.StringOutput { 262 return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.Encoding }).(pulumi.StringOutput) 263 } 264 265 // The MD5 message digest of the SSH public key. 266 func (o SshKeyOutput) Fingerprint() pulumi.StringOutput { 267 return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.Fingerprint }).(pulumi.StringOutput) 268 } 269 270 // The SSH public key. The public key must be encoded in ssh-rsa format or PEM format. 271 func (o SshKeyOutput) PublicKey() pulumi.StringOutput { 272 return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.PublicKey }).(pulumi.StringOutput) 273 } 274 275 // The unique identifier for the SSH public key. 276 func (o SshKeyOutput) SshPublicKeyId() pulumi.StringOutput { 277 return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.SshPublicKeyId }).(pulumi.StringOutput) 278 } 279 280 // The status to assign to the SSH public key. Active means the key can be used for authentication with an AWS CodeCommit repository. Inactive means the key cannot be used. Default is `active`. 281 func (o SshKeyOutput) Status() pulumi.StringOutput { 282 return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput) 283 } 284 285 // The name of the IAM user to associate the SSH public key with. 286 func (o SshKeyOutput) Username() pulumi.StringOutput { 287 return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.Username }).(pulumi.StringOutput) 288 } 289 290 type SshKeyArrayOutput struct{ *pulumi.OutputState } 291 292 func (SshKeyArrayOutput) ElementType() reflect.Type { 293 return reflect.TypeOf((*[]*SshKey)(nil)).Elem() 294 } 295 296 func (o SshKeyArrayOutput) ToSshKeyArrayOutput() SshKeyArrayOutput { 297 return o 298 } 299 300 func (o SshKeyArrayOutput) ToSshKeyArrayOutputWithContext(ctx context.Context) SshKeyArrayOutput { 301 return o 302 } 303 304 func (o SshKeyArrayOutput) Index(i pulumi.IntInput) SshKeyOutput { 305 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SshKey { 306 return vs[0].([]*SshKey)[vs[1].(int)] 307 }).(SshKeyOutput) 308 } 309 310 type SshKeyMapOutput struct{ *pulumi.OutputState } 311 312 func (SshKeyMapOutput) ElementType() reflect.Type { 313 return reflect.TypeOf((*map[string]*SshKey)(nil)).Elem() 314 } 315 316 func (o SshKeyMapOutput) ToSshKeyMapOutput() SshKeyMapOutput { 317 return o 318 } 319 320 func (o SshKeyMapOutput) ToSshKeyMapOutputWithContext(ctx context.Context) SshKeyMapOutput { 321 return o 322 } 323 324 func (o SshKeyMapOutput) MapIndex(k pulumi.StringInput) SshKeyOutput { 325 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SshKey { 326 return vs[0].(map[string]*SshKey)[vs[1].(string)] 327 }).(SshKeyOutput) 328 } 329 330 func init() { 331 pulumi.RegisterInputType(reflect.TypeOf((*SshKeyInput)(nil)).Elem(), &SshKey{}) 332 pulumi.RegisterInputType(reflect.TypeOf((*SshKeyArrayInput)(nil)).Elem(), SshKeyArray{}) 333 pulumi.RegisterInputType(reflect.TypeOf((*SshKeyMapInput)(nil)).Elem(), SshKeyMap{}) 334 pulumi.RegisterOutputType(SshKeyOutput{}) 335 pulumi.RegisterOutputType(SshKeyArrayOutput{}) 336 pulumi.RegisterOutputType(SshKeyMapOutput{}) 337 }