Skip to content

Commit

Permalink
resource/alicloud_kms_secret: Added error code Forbidden.ResourceNotF…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
MrWolong committed Jun 18, 2024
1 parent 3430b2d commit 6ec38a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions alicloud/resource_alicloud_kms_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ func resourceAliCloudKmsSecretRead(d *schema.ResourceData, meta interface{}) err
if dkmsInstanceId != "" {
policy, err := kmsService.DescribeKmsSecretPolicy(d.Id())
if err != nil {
if !d.IsNewResource() && NotFoundError(err) {
return nil
}

return WrapError(err)
}

Expand Down
11 changes: 5 additions & 6 deletions alicloud/resource_alicloud_kms_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,17 +672,16 @@ func AliCloudKmsSecretBasicDependence1(name string) string {
data "alicloud_zones" "default" {
}
data "alicloud_instance_types" "default" {
availability_zone = data.alicloud_zones.default.zones.0.id
instance_type_family = "ecs.sn1ne"
}
data "alicloud_images" "default" {
name_regex = "^ubuntu_[0-9]+_[0-9]+_x64*"
most_recent = true
owners = "system"
}
data "alicloud_instance_types" "default" {
availability_zone = data.alicloud_zones.default.zones.0.id
image_id = data.alicloud_images.default.images.0.id
}
data "alicloud_vpcs" "default" {
name_regex = "^default-NODELETING$"
}
Expand Down
3 changes: 3 additions & 0 deletions alicloud/service_alicloud_kms.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ func (s *KmsService) DescribeKmsSecretPolicy(id string) (object map[string]inter
addDebug(action, response, request)

if err != nil {
if IsExpectedErrors(err, []string{"Forbidden.ResourceNotFound"}) {
return object, WrapErrorf(Error(GetNotFoundMessage("Kms:Secret", id)), NotFoundMsg, ProviderERROR, fmt.Sprint(response["RequestId"]))
}
return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR)
}

Expand Down

0 comments on commit 6ec38a8

Please sign in to comment.