Skip to content

Commit

Permalink
Fix alicloud_ram_user_policy_attachment EntityNotExist.User error
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Oct 8, 2018
1 parent 1df2a9c commit d5ddce9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ IMPROVEMENTS:

BUG FIXES:

- Fix alicloud_ram_user_policy_attachment EntityNotExist.User error ([#712](https://github.com/alibaba/terraform-provider/pull/712))
- Add wait time to fix random detaching disk error ([#703](https://github.com/alibaba/terraform-provider/pull/703))

## 1.17.0 (September 22, 2018)
Expand Down
15 changes: 15 additions & 0 deletions alicloud/resource_alicloud_ram_user_policy_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func resourceAlicloudRamUserPolicyAttachmentCreate(d *schema.ResourceData, meta
func resourceAlicloudRamUserPolicyAttachmentRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AliyunClient).ramconn

// In order to be compatible with previous Id (before 1.9.6) which format to user<policuy_name><policy_type><user_name>
id := fmt.Sprintf("%s%s%s%s%s", d.Get("user_name").(string), COLON_SEPARATED, d.Get("policy_name").(string), COLON_SEPARATED, d.Get("policy_type").(string))

if d.Id() != id {
d.SetId(id)
}

split := strings.Split(d.Id(), COLON_SEPARATED)
args := ram.UserQueryRequest{
UserName: split[0],
Expand Down Expand Up @@ -89,6 +96,14 @@ func resourceAlicloudRamUserPolicyAttachmentRead(d *schema.ResourceData, meta in

func resourceAlicloudRamUserPolicyAttachmentDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AliyunClient).ramconn

// In order to be compatible with previous Id (before 1.9.6) which format to user<policuy_name><policy_type><user_name>
id := fmt.Sprintf("%s%s%s%s%s", d.Get("user_name").(string), COLON_SEPARATED, d.Get("policy_name").(string), COLON_SEPARATED, d.Get("policy_type").(string))

if d.Id() != id {
d.SetId(id)
}

split := strings.Split(d.Id(), COLON_SEPARATED)

args := ram.AttachPolicyRequest{
Expand Down

0 comments on commit d5ddce9

Please sign in to comment.