github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getAmi.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 ec2 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 // Use this data source to get the ID of a registered AMI for use in other 15 // resources. 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/ec2" 26 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 27 // 28 // ) 29 // 30 // func main() { 31 // pulumi.Run(func(ctx *pulumi.Context) error { 32 // _, err := ec2.LookupAmi(ctx, &ec2.LookupAmiArgs{ 33 // ExecutableUsers: []string{ 34 // "self", 35 // }, 36 // MostRecent: pulumi.BoolRef(true), 37 // NameRegex: pulumi.StringRef("^myami-\\d{3}"), 38 // Owners: []string{ 39 // "self", 40 // }, 41 // Filters: []ec2.GetAmiFilter{ 42 // { 43 // Name: "name", 44 // Values: []string{ 45 // "myami-*", 46 // }, 47 // }, 48 // { 49 // Name: "root-device-type", 50 // Values: []string{ 51 // "ebs", 52 // }, 53 // }, 54 // { 55 // Name: "virtualization-type", 56 // Values: []string{ 57 // "hvm", 58 // }, 59 // }, 60 // }, 61 // }, nil) 62 // if err != nil { 63 // return err 64 // } 65 // return nil 66 // }) 67 // } 68 // 69 // ``` 70 // <!--End PulumiCodeChooser --> 71 func LookupAmi(ctx *pulumi.Context, args *LookupAmiArgs, opts ...pulumi.InvokeOption) (*LookupAmiResult, error) { 72 opts = internal.PkgInvokeDefaultOpts(opts) 73 var rv LookupAmiResult 74 err := ctx.Invoke("aws:ec2/getAmi:getAmi", args, &rv, opts...) 75 if err != nil { 76 return nil, err 77 } 78 return &rv, nil 79 } 80 81 // A collection of arguments for invoking getAmi. 82 type LookupAmiArgs struct { 83 // Limit search to users with *explicit* launch permission on 84 // the image. Valid items are the numeric account ID or `self`. 85 ExecutableUsers []string `pulumi:"executableUsers"` 86 // One or more name/value pairs to filter off of. There are 87 // several valid keys, for a full reference, check out 88 // [describe-images in the AWS CLI reference][1]. 89 Filters []GetAmiFilter `pulumi:"filters"` 90 // If true, all deprecated AMIs are included in the response. If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false. 91 IncludeDeprecated *bool `pulumi:"includeDeprecated"` 92 // If more than one result is returned, use the most 93 // recent AMI. 94 MostRecent *bool `pulumi:"mostRecent"` 95 // Regex string to apply to the AMI list returned 96 // by AWS. This allows more advanced filtering not supported from the AWS API. This 97 // filtering is done locally on what AWS returns, and could have a performance 98 // impact if the result is large. Combine this with other 99 // options to narrow down the list AWS returns. 100 // 101 // > **NOTE:** If more or less than a single match is returned by the search, 102 // this call will fail. Ensure that your search is specific enough to return 103 // a single AMI ID only, or use `mostRecent` to choose the most recent one. If 104 // you want to match multiple AMIs, use the `ec2.getAmiIds` data source instead. 105 NameRegex *string `pulumi:"nameRegex"` 106 // List of AMI owners to limit search. Valid values: an AWS account ID, `self` (the current account), or an AWS owner alias (e.g., `amazon`, `aws-marketplace`, `microsoft`). 107 Owners []string `pulumi:"owners"` 108 // Any tags assigned to the image. 109 // * `tags.#.key` - Key name of the tag. 110 // * `tags.#.value` - Value of the tag. 111 Tags map[string]string `pulumi:"tags"` 112 } 113 114 // A collection of values returned by getAmi. 115 type LookupAmiResult struct { 116 // OS architecture of the AMI (ie: `i386` or `x8664`). 117 Architecture string `pulumi:"architecture"` 118 // ARN of the AMI. 119 Arn string `pulumi:"arn"` 120 // Set of objects with block device mappings of the AMI. 121 BlockDeviceMappings []GetAmiBlockDeviceMapping `pulumi:"blockDeviceMappings"` 122 // Boot mode of the image. 123 BootMode string `pulumi:"bootMode"` 124 // Date and time the image was created. 125 CreationDate string `pulumi:"creationDate"` 126 // Date and time when the image will be deprecated. 127 DeprecationTime string `pulumi:"deprecationTime"` 128 // Description of the AMI that was provided during image 129 // creation. 130 Description string `pulumi:"description"` 131 // Whether enhanced networking with ENA is enabled. 132 EnaSupport bool `pulumi:"enaSupport"` 133 ExecutableUsers []string `pulumi:"executableUsers"` 134 Filters []GetAmiFilter `pulumi:"filters"` 135 // Hypervisor type of the image. 136 Hypervisor string `pulumi:"hypervisor"` 137 // The provider-assigned unique ID for this managed resource. 138 Id string `pulumi:"id"` 139 // ID of the AMI. Should be the same as the resource `id`. 140 ImageId string `pulumi:"imageId"` 141 // Location of the AMI. 142 ImageLocation string `pulumi:"imageLocation"` 143 // AWS account alias (for example, `amazon`, `self`) or 144 // the AWS account ID of the AMI owner. 145 ImageOwnerAlias string `pulumi:"imageOwnerAlias"` 146 // Type of image. 147 ImageType string `pulumi:"imageType"` 148 // Instance Metadata Service (IMDS) support mode for the image. Set to `v2.0` if instances ran from this image enforce IMDSv2. 149 ImdsSupport string `pulumi:"imdsSupport"` 150 IncludeDeprecated *bool `pulumi:"includeDeprecated"` 151 // Kernel associated with the image, if any. Only applicable 152 // for machine images. 153 KernelId string `pulumi:"kernelId"` 154 MostRecent *bool `pulumi:"mostRecent"` 155 // Name of the AMI that was provided during image creation. 156 Name string `pulumi:"name"` 157 NameRegex *string `pulumi:"nameRegex"` 158 // AWS account ID of the image owner. 159 OwnerId string `pulumi:"ownerId"` 160 Owners []string `pulumi:"owners"` 161 // Value is Windows for `Windows` AMIs; otherwise blank. 162 Platform string `pulumi:"platform"` 163 // Platform details associated with the billing code of the AMI. 164 PlatformDetails string `pulumi:"platformDetails"` 165 // Any product codes associated with the AMI. 166 // * `product_codes.#.product_code_id` - The product code. 167 // * `product_codes.#.product_code_type` - The type of product code. 168 ProductCodes []GetAmiProductCode `pulumi:"productCodes"` 169 // `true` if the image has public launch permissions. 170 Public bool `pulumi:"public"` 171 // RAM disk associated with the image, if any. Only applicable 172 // for machine images. 173 RamdiskId string `pulumi:"ramdiskId"` 174 // Device name of the root device. 175 RootDeviceName string `pulumi:"rootDeviceName"` 176 // Type of root device (ie: `ebs` or `instance-store`). 177 RootDeviceType string `pulumi:"rootDeviceType"` 178 // Snapshot id associated with the root device, if any 179 // (only applies to `ebs` root devices). 180 RootSnapshotId string `pulumi:"rootSnapshotId"` 181 // Whether enhanced networking is enabled. 182 SriovNetSupport string `pulumi:"sriovNetSupport"` 183 // Current state of the AMI. If the state is `available`, the image 184 // is successfully registered and can be used to launch an instance. 185 State string `pulumi:"state"` 186 // Describes a state change. Fields are `UNSET` if not available. 187 StateReason map[string]string `pulumi:"stateReason"` 188 // Any tags assigned to the image. 189 // * `tags.#.key` - Key name of the tag. 190 // * `tags.#.value` - Value of the tag. 191 Tags map[string]string `pulumi:"tags"` 192 // If the image is configured for NitroTPM support, the value is `v2.0`. 193 TpmSupport string `pulumi:"tpmSupport"` 194 // Operation of the Amazon EC2 instance and the billing code that is associated with the AMI. 195 UsageOperation string `pulumi:"usageOperation"` 196 // Type of virtualization of the AMI (ie: `hvm` or 197 // `paravirtual`). 198 VirtualizationType string `pulumi:"virtualizationType"` 199 } 200 201 func LookupAmiOutput(ctx *pulumi.Context, args LookupAmiOutputArgs, opts ...pulumi.InvokeOption) LookupAmiResultOutput { 202 return pulumi.ToOutputWithContext(context.Background(), args). 203 ApplyT(func(v interface{}) (LookupAmiResult, error) { 204 args := v.(LookupAmiArgs) 205 r, err := LookupAmi(ctx, &args, opts...) 206 var s LookupAmiResult 207 if r != nil { 208 s = *r 209 } 210 return s, err 211 }).(LookupAmiResultOutput) 212 } 213 214 // A collection of arguments for invoking getAmi. 215 type LookupAmiOutputArgs struct { 216 // Limit search to users with *explicit* launch permission on 217 // the image. Valid items are the numeric account ID or `self`. 218 ExecutableUsers pulumi.StringArrayInput `pulumi:"executableUsers"` 219 // One or more name/value pairs to filter off of. There are 220 // several valid keys, for a full reference, check out 221 // [describe-images in the AWS CLI reference][1]. 222 Filters GetAmiFilterArrayInput `pulumi:"filters"` 223 // If true, all deprecated AMIs are included in the response. If false, no deprecated AMIs are included in the response. If no value is specified, the default value is false. 224 IncludeDeprecated pulumi.BoolPtrInput `pulumi:"includeDeprecated"` 225 // If more than one result is returned, use the most 226 // recent AMI. 227 MostRecent pulumi.BoolPtrInput `pulumi:"mostRecent"` 228 // Regex string to apply to the AMI list returned 229 // by AWS. This allows more advanced filtering not supported from the AWS API. This 230 // filtering is done locally on what AWS returns, and could have a performance 231 // impact if the result is large. Combine this with other 232 // options to narrow down the list AWS returns. 233 // 234 // > **NOTE:** If more or less than a single match is returned by the search, 235 // this call will fail. Ensure that your search is specific enough to return 236 // a single AMI ID only, or use `mostRecent` to choose the most recent one. If 237 // you want to match multiple AMIs, use the `ec2.getAmiIds` data source instead. 238 NameRegex pulumi.StringPtrInput `pulumi:"nameRegex"` 239 // List of AMI owners to limit search. Valid values: an AWS account ID, `self` (the current account), or an AWS owner alias (e.g., `amazon`, `aws-marketplace`, `microsoft`). 240 Owners pulumi.StringArrayInput `pulumi:"owners"` 241 // Any tags assigned to the image. 242 // * `tags.#.key` - Key name of the tag. 243 // * `tags.#.value` - Value of the tag. 244 Tags pulumi.StringMapInput `pulumi:"tags"` 245 } 246 247 func (LookupAmiOutputArgs) ElementType() reflect.Type { 248 return reflect.TypeOf((*LookupAmiArgs)(nil)).Elem() 249 } 250 251 // A collection of values returned by getAmi. 252 type LookupAmiResultOutput struct{ *pulumi.OutputState } 253 254 func (LookupAmiResultOutput) ElementType() reflect.Type { 255 return reflect.TypeOf((*LookupAmiResult)(nil)).Elem() 256 } 257 258 func (o LookupAmiResultOutput) ToLookupAmiResultOutput() LookupAmiResultOutput { 259 return o 260 } 261 262 func (o LookupAmiResultOutput) ToLookupAmiResultOutputWithContext(ctx context.Context) LookupAmiResultOutput { 263 return o 264 } 265 266 // OS architecture of the AMI (ie: `i386` or `x8664`). 267 func (o LookupAmiResultOutput) Architecture() pulumi.StringOutput { 268 return o.ApplyT(func(v LookupAmiResult) string { return v.Architecture }).(pulumi.StringOutput) 269 } 270 271 // ARN of the AMI. 272 func (o LookupAmiResultOutput) Arn() pulumi.StringOutput { 273 return o.ApplyT(func(v LookupAmiResult) string { return v.Arn }).(pulumi.StringOutput) 274 } 275 276 // Set of objects with block device mappings of the AMI. 277 func (o LookupAmiResultOutput) BlockDeviceMappings() GetAmiBlockDeviceMappingArrayOutput { 278 return o.ApplyT(func(v LookupAmiResult) []GetAmiBlockDeviceMapping { return v.BlockDeviceMappings }).(GetAmiBlockDeviceMappingArrayOutput) 279 } 280 281 // Boot mode of the image. 282 func (o LookupAmiResultOutput) BootMode() pulumi.StringOutput { 283 return o.ApplyT(func(v LookupAmiResult) string { return v.BootMode }).(pulumi.StringOutput) 284 } 285 286 // Date and time the image was created. 287 func (o LookupAmiResultOutput) CreationDate() pulumi.StringOutput { 288 return o.ApplyT(func(v LookupAmiResult) string { return v.CreationDate }).(pulumi.StringOutput) 289 } 290 291 // Date and time when the image will be deprecated. 292 func (o LookupAmiResultOutput) DeprecationTime() pulumi.StringOutput { 293 return o.ApplyT(func(v LookupAmiResult) string { return v.DeprecationTime }).(pulumi.StringOutput) 294 } 295 296 // Description of the AMI that was provided during image 297 // creation. 298 func (o LookupAmiResultOutput) Description() pulumi.StringOutput { 299 return o.ApplyT(func(v LookupAmiResult) string { return v.Description }).(pulumi.StringOutput) 300 } 301 302 // Whether enhanced networking with ENA is enabled. 303 func (o LookupAmiResultOutput) EnaSupport() pulumi.BoolOutput { 304 return o.ApplyT(func(v LookupAmiResult) bool { return v.EnaSupport }).(pulumi.BoolOutput) 305 } 306 307 func (o LookupAmiResultOutput) ExecutableUsers() pulumi.StringArrayOutput { 308 return o.ApplyT(func(v LookupAmiResult) []string { return v.ExecutableUsers }).(pulumi.StringArrayOutput) 309 } 310 311 func (o LookupAmiResultOutput) Filters() GetAmiFilterArrayOutput { 312 return o.ApplyT(func(v LookupAmiResult) []GetAmiFilter { return v.Filters }).(GetAmiFilterArrayOutput) 313 } 314 315 // Hypervisor type of the image. 316 func (o LookupAmiResultOutput) Hypervisor() pulumi.StringOutput { 317 return o.ApplyT(func(v LookupAmiResult) string { return v.Hypervisor }).(pulumi.StringOutput) 318 } 319 320 // The provider-assigned unique ID for this managed resource. 321 func (o LookupAmiResultOutput) Id() pulumi.StringOutput { 322 return o.ApplyT(func(v LookupAmiResult) string { return v.Id }).(pulumi.StringOutput) 323 } 324 325 // ID of the AMI. Should be the same as the resource `id`. 326 func (o LookupAmiResultOutput) ImageId() pulumi.StringOutput { 327 return o.ApplyT(func(v LookupAmiResult) string { return v.ImageId }).(pulumi.StringOutput) 328 } 329 330 // Location of the AMI. 331 func (o LookupAmiResultOutput) ImageLocation() pulumi.StringOutput { 332 return o.ApplyT(func(v LookupAmiResult) string { return v.ImageLocation }).(pulumi.StringOutput) 333 } 334 335 // AWS account alias (for example, `amazon`, `self`) or 336 // the AWS account ID of the AMI owner. 337 func (o LookupAmiResultOutput) ImageOwnerAlias() pulumi.StringOutput { 338 return o.ApplyT(func(v LookupAmiResult) string { return v.ImageOwnerAlias }).(pulumi.StringOutput) 339 } 340 341 // Type of image. 342 func (o LookupAmiResultOutput) ImageType() pulumi.StringOutput { 343 return o.ApplyT(func(v LookupAmiResult) string { return v.ImageType }).(pulumi.StringOutput) 344 } 345 346 // Instance Metadata Service (IMDS) support mode for the image. Set to `v2.0` if instances ran from this image enforce IMDSv2. 347 func (o LookupAmiResultOutput) ImdsSupport() pulumi.StringOutput { 348 return o.ApplyT(func(v LookupAmiResult) string { return v.ImdsSupport }).(pulumi.StringOutput) 349 } 350 351 func (o LookupAmiResultOutput) IncludeDeprecated() pulumi.BoolPtrOutput { 352 return o.ApplyT(func(v LookupAmiResult) *bool { return v.IncludeDeprecated }).(pulumi.BoolPtrOutput) 353 } 354 355 // Kernel associated with the image, if any. Only applicable 356 // for machine images. 357 func (o LookupAmiResultOutput) KernelId() pulumi.StringOutput { 358 return o.ApplyT(func(v LookupAmiResult) string { return v.KernelId }).(pulumi.StringOutput) 359 } 360 361 func (o LookupAmiResultOutput) MostRecent() pulumi.BoolPtrOutput { 362 return o.ApplyT(func(v LookupAmiResult) *bool { return v.MostRecent }).(pulumi.BoolPtrOutput) 363 } 364 365 // Name of the AMI that was provided during image creation. 366 func (o LookupAmiResultOutput) Name() pulumi.StringOutput { 367 return o.ApplyT(func(v LookupAmiResult) string { return v.Name }).(pulumi.StringOutput) 368 } 369 370 func (o LookupAmiResultOutput) NameRegex() pulumi.StringPtrOutput { 371 return o.ApplyT(func(v LookupAmiResult) *string { return v.NameRegex }).(pulumi.StringPtrOutput) 372 } 373 374 // AWS account ID of the image owner. 375 func (o LookupAmiResultOutput) OwnerId() pulumi.StringOutput { 376 return o.ApplyT(func(v LookupAmiResult) string { return v.OwnerId }).(pulumi.StringOutput) 377 } 378 379 func (o LookupAmiResultOutput) Owners() pulumi.StringArrayOutput { 380 return o.ApplyT(func(v LookupAmiResult) []string { return v.Owners }).(pulumi.StringArrayOutput) 381 } 382 383 // Value is Windows for `Windows` AMIs; otherwise blank. 384 func (o LookupAmiResultOutput) Platform() pulumi.StringOutput { 385 return o.ApplyT(func(v LookupAmiResult) string { return v.Platform }).(pulumi.StringOutput) 386 } 387 388 // Platform details associated with the billing code of the AMI. 389 func (o LookupAmiResultOutput) PlatformDetails() pulumi.StringOutput { 390 return o.ApplyT(func(v LookupAmiResult) string { return v.PlatformDetails }).(pulumi.StringOutput) 391 } 392 393 // Any product codes associated with the AMI. 394 // * `product_codes.#.product_code_id` - The product code. 395 // * `product_codes.#.product_code_type` - The type of product code. 396 func (o LookupAmiResultOutput) ProductCodes() GetAmiProductCodeArrayOutput { 397 return o.ApplyT(func(v LookupAmiResult) []GetAmiProductCode { return v.ProductCodes }).(GetAmiProductCodeArrayOutput) 398 } 399 400 // `true` if the image has public launch permissions. 401 func (o LookupAmiResultOutput) Public() pulumi.BoolOutput { 402 return o.ApplyT(func(v LookupAmiResult) bool { return v.Public }).(pulumi.BoolOutput) 403 } 404 405 // RAM disk associated with the image, if any. Only applicable 406 // for machine images. 407 func (o LookupAmiResultOutput) RamdiskId() pulumi.StringOutput { 408 return o.ApplyT(func(v LookupAmiResult) string { return v.RamdiskId }).(pulumi.StringOutput) 409 } 410 411 // Device name of the root device. 412 func (o LookupAmiResultOutput) RootDeviceName() pulumi.StringOutput { 413 return o.ApplyT(func(v LookupAmiResult) string { return v.RootDeviceName }).(pulumi.StringOutput) 414 } 415 416 // Type of root device (ie: `ebs` or `instance-store`). 417 func (o LookupAmiResultOutput) RootDeviceType() pulumi.StringOutput { 418 return o.ApplyT(func(v LookupAmiResult) string { return v.RootDeviceType }).(pulumi.StringOutput) 419 } 420 421 // Snapshot id associated with the root device, if any 422 // (only applies to `ebs` root devices). 423 func (o LookupAmiResultOutput) RootSnapshotId() pulumi.StringOutput { 424 return o.ApplyT(func(v LookupAmiResult) string { return v.RootSnapshotId }).(pulumi.StringOutput) 425 } 426 427 // Whether enhanced networking is enabled. 428 func (o LookupAmiResultOutput) SriovNetSupport() pulumi.StringOutput { 429 return o.ApplyT(func(v LookupAmiResult) string { return v.SriovNetSupport }).(pulumi.StringOutput) 430 } 431 432 // Current state of the AMI. If the state is `available`, the image 433 // is successfully registered and can be used to launch an instance. 434 func (o LookupAmiResultOutput) State() pulumi.StringOutput { 435 return o.ApplyT(func(v LookupAmiResult) string { return v.State }).(pulumi.StringOutput) 436 } 437 438 // Describes a state change. Fields are `UNSET` if not available. 439 func (o LookupAmiResultOutput) StateReason() pulumi.StringMapOutput { 440 return o.ApplyT(func(v LookupAmiResult) map[string]string { return v.StateReason }).(pulumi.StringMapOutput) 441 } 442 443 // Any tags assigned to the image. 444 // * `tags.#.key` - Key name of the tag. 445 // * `tags.#.value` - Value of the tag. 446 func (o LookupAmiResultOutput) Tags() pulumi.StringMapOutput { 447 return o.ApplyT(func(v LookupAmiResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput) 448 } 449 450 // If the image is configured for NitroTPM support, the value is `v2.0`. 451 func (o LookupAmiResultOutput) TpmSupport() pulumi.StringOutput { 452 return o.ApplyT(func(v LookupAmiResult) string { return v.TpmSupport }).(pulumi.StringOutput) 453 } 454 455 // Operation of the Amazon EC2 instance and the billing code that is associated with the AMI. 456 func (o LookupAmiResultOutput) UsageOperation() pulumi.StringOutput { 457 return o.ApplyT(func(v LookupAmiResult) string { return v.UsageOperation }).(pulumi.StringOutput) 458 } 459 460 // Type of virtualization of the AMI (ie: `hvm` or 461 // `paravirtual`). 462 func (o LookupAmiResultOutput) VirtualizationType() pulumi.StringOutput { 463 return o.ApplyT(func(v LookupAmiResult) string { return v.VirtualizationType }).(pulumi.StringOutput) 464 } 465 466 func init() { 467 pulumi.RegisterOutputType(LookupAmiResultOutput{}) 468 }