Skip to content

Commit

Permalink
Add owner_id to resource_aws_ami
Browse files Browse the repository at this point in the history
  • Loading branch information
shuheiktgw committed Jan 20, 2021
1 parent 62da40c commit 6fbbd8b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aws/resource_aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ func resourceAwsAmi() *schema.Resource {
Required: true,
ForceNew: true,
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
},
"ramdisk_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -376,6 +380,7 @@ func resourceAwsAmiRead(d *schema.ResourceData, meta interface{}) error {
d.Set("image_location", image.ImageLocation)
d.Set("architecture", image.Architecture)
d.Set("kernel_id", image.KernelId)
d.Set("owner_id", image.OwnerId)
d.Set("ramdisk_id", image.RamdiskId)
d.Set("root_device_name", image.RootDeviceName)
d.Set("root_snapshot_id", amiRootSnapshotId(image))
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_ami_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func resourceAwsAmiCopy() *schema.Resource {
Required: true,
ForceNew: true,
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
},
"ramdisk_id": {
Type: schema.TypeString,
Computed: true,
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_ami_from_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func resourceAwsAmiFromInstance() *schema.Resource {
Required: true,
ForceNew: true,
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
},
"ramdisk_id": {
Type: schema.TypeString,
Computed: true,
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_ami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestAccAWSAMI_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "ephemeral_block_device.#", "0"),
resource.TestCheckResourceAttr(resourceName, "kernel_id", ""),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
resource.TestCheckResourceAttr(resourceName, "ramdisk_id", ""),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttrPair(resourceName, "root_snapshot_id", snapshotResourceName, "id"),
Expand Down Expand Up @@ -102,6 +103,7 @@ func TestAccAWSAMI_description(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "ephemeral_block_device.#", "0"),
resource.TestCheckResourceAttr(resourceName, "kernel_id", ""),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
resource.TestCheckResourceAttr(resourceName, "ramdisk_id", ""),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttrPair(resourceName, "root_snapshot_id", snapshotResourceName, "id"),
Expand Down Expand Up @@ -140,6 +142,7 @@ func TestAccAWSAMI_description(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "ephemeral_block_device.#", "0"),
resource.TestCheckResourceAttr(resourceName, "kernel_id", ""),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
resource.TestCheckResourceAttr(resourceName, "ramdisk_id", ""),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttrPair(resourceName, "root_snapshot_id", snapshotResourceName, "id"),
Expand Down Expand Up @@ -214,6 +217,7 @@ func TestAccAWSAMI_EphemeralBlockDevices(t *testing.T) {
}),
resource.TestCheckResourceAttr(resourceName, "kernel_id", ""),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
resource.TestCheckResourceAttr(resourceName, "ramdisk_id", ""),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttrPair(resourceName, "root_snapshot_id", snapshotResourceName, "id"),
Expand Down Expand Up @@ -276,6 +280,7 @@ func TestAccAWSAMI_Gp3BlockDevice(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "ephemeral_block_device.#", "0"),
resource.TestCheckResourceAttr(resourceName, "kernel_id", ""),
resource.TestCheckResourceAttr(resourceName, "name", rName),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
resource.TestCheckResourceAttr(resourceName, "ramdisk_id", ""),
resource.TestCheckResourceAttr(resourceName, "root_device_name", "/dev/sda1"),
resource.TestCheckResourceAttrPair(resourceName, "root_snapshot_id", snapshotResourceName, "id"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/ami.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ In addition to all arguments above, the following attributes are exported:

* `arn` - The ARN of the AMI.
* `id` - The ID of the created AMI.
* `owner_id` - The AWS account ID of the image owner.
* `root_snapshot_id` - The Snapshot ID for the root volume (for EBS-backed AMIs)

## Import
Expand Down

0 comments on commit 6fbbd8b

Please sign in to comment.