-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding tags attribute to KMS key resource #522
Conversation
Signed-off-by: Rohit Joshi <rohit.prasad.joshi@sap.com>
libraries/aws_kms_key.rb
Outdated
begin | ||
tag_list = @aws.kms_client.list_resource_tags(key_id: @display_name).tags | ||
rescue | ||
return {} | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use catch_aws_errors
instead of custom begin; rescue
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sathish-progress can you please suggest a change ? I am getting a permission error when I try to use 'catch_aws_errors' block. It works fine with current implementation. Additionally, in majority of other resources begin; rescue block is used for tags method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right about most existing resources using begin; rescue
block, I am currently investigating that..
libraries/aws_kms_key.rb
Outdated
def tags | ||
begin | ||
tag_list = @aws.kms_client.list_resource_tags(key_id: @display_name).tags | ||
rescue | ||
return {} | ||
end | ||
kms_tags(tag_list) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I tried the below, I was able to query the tags successfully,
def tags | |
begin | |
tag_list = @aws.kms_client.list_resource_tags(key_id: @display_name).tags | |
rescue | |
return {} | |
end | |
kms_tags(tag_list) | |
end | |
def tags | |
catch_aws_errors do | |
tag_list = @aws.kms_client.list_resource_tags(key_id: @display_name).tags | |
kms_tags(tag_list) | |
end | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: Rohit Joshi <rohit.prasad.joshi@sap.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
docs/resources/aws_kms_key.md
Outdated
@@ -56,6 +56,7 @@ See also the [AWS documentation on KS Keys](https://docs.aws.amazon.com/kms/late | |||
|description | The description of the key. | | |||
|deletion\_time | Specifies the date and time after which AWS KMS deletes the key. This value is present only when KeyState is PendingDeletion, otherwise this value is nil. | | |||
|invalidation\_time | Provides the date and time until the key is not valid. Once the key is not valid, AWS KMS deletes the key and it becomes unusable. This value will be null unless the keys Origin is EXTERNAL and its matcher have\_key\_expiration is set to true. | | |||
|tags | An hash with each key-value pair corresponding to a tag associated with the entity | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|tags | An hash with each key-value pair corresponding to a tag associated with the entity | | |
|tags | A hash with each key-value pair corresponding to a tag associated with the entity. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: Rohit Joshi <rohit.prasad.joshi@sap.com>
@IanMadd Can you please approve if the review is done? |
Kudos, SonarCloud Quality Gate passed!
|
Signed-off-by: Rohit Joshi rohit.prasad.joshi@sap.com
Description
Please describe what this change achieves. Ensure you have read the Contributing to InSpec AWS document before submitting.
Issues Resolved
List any existing issues this PR resolves, or any Discourse or StackOverflow discussion that's relevant
Check List
Please fill box or appropriate ([x]) or mark N/A.
rake lint
passes