Skip to content
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

Merged
merged 7 commits into from
Sep 30, 2021

Conversation

Rohit1509
Copy link

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.

Signed-off-by: Rohit Joshi <rohit.prasad.joshi@sap.com>
Comment on lines 52 to 56
begin
tag_list = @aws.kms_client.list_resource_tags(key_id: @display_name).tags
rescue
return {}
end
Copy link
Contributor

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

Copy link
Author

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

Copy link
Contributor

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..

@sathish-progress sathish-progress added CFT Support Version: Bump Minor Used by github.minor_bump_labels to bump the Minor version number. labels Sep 1, 2021
Comment on lines 51 to 58
def tags
begin
tag_list = @aws.kms_client.list_resource_tags(key_id: @display_name).tags
rescue
return {}
end
kms_tags(tag_list)
end
Copy link
Contributor

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,

Suggested change
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

Copy link
Author

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>
Copy link
Contributor

@sathish-progress sathish-progress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -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 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|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. |

Copy link
Author

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>
@soumyo13
Copy link
Contributor

@IanMadd Can you please approve if the review is done?

@sonarcloud
Copy link

sonarcloud bot commented Sep 30, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.1% 0.1% Duplication

@sathish-progress sathish-progress merged commit af86386 into inspec:main Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CFT Support Documentation Version: Bump Minor Used by github.minor_bump_labels to bump the Minor version number.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants