Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3643.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_cvm_sync_image: add computed `image_set`
```
34 changes: 30 additions & 4 deletions tencentcloud/services/cvm/resource_tc_cvm_sync_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,20 @@ func ResourceTencentCloudCvmSyncImage() *schema.Resource {

"image_set": {
Computed: true,
Type: schema.TypeSet,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"image_id": {
Type: schema.TypeString,
Computed: true,
Description: "Image ID.",
},
"region": {
Type: schema.TypeString,
Computed: true,
Description: "Region of the image.",
},
},
},
Description: "ID of the image created in the destination region.",
},
Expand Down Expand Up @@ -145,7 +156,22 @@ func resourceTencentCloudCvmSyncImageCreate(d *schema.ResourceData, meta interfa

d.SetId(imageId)

_ = d.Set("image_set", response.Response.ImageSet)
imageSetList := []interface{}{}
for _, image := range response.Response.ImageSet {
imageMap := map[string]interface{}{}

if image.ImageId != nil {
imageMap["image_id"] = image.ImageId
}

if image.Region != nil {
imageMap["region"] = image.Region
}

imageSetList = append(imageSetList, imageMap)
}

_ = d.Set("image_set", imageSetList)

service := CvmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/cvm_sync_image.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ In addition to all arguments above, the following attributes are exported:

* `id` - ID of the resource.
* `image_set` - ID of the image created in the destination region.
* `image_id` - Image ID.
* `region` - Region of the image.


Loading