Skip to content

Commit

Permalink
Use the built in required_by logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Feb 20, 2020
1 parent 56e1ad7 commit c977459
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/ansible/modules/cloud/amazon/s3_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,12 @@ def main():
encryption_key_id=dict()
)

required_by = dict(
encryption_key_id=('encryption',),
)

module = AnsibleAWSModule(
argument_spec=argument_spec,
argument_spec=argument_spec, required_by=required_by
)

region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module, boto3=True)
Expand Down Expand Up @@ -726,10 +730,9 @@ def main():
if not hasattr(s3_client, "get_bucket_encryption"):
if encryption is not None:
module.fail_json(msg="Using bucket encryption requires botocore version >= 1.7.41")

# Parameter validation
if encryption_key_id is not None and encryption is None:
module.fail_json(msg="You must specify encryption parameter along with encryption_key_id.")
elif encryption_key_id is not None and encryption != 'aws:kms':
if encryption_key_id is not None and encryption != 'aws:kms':
module.fail_json(msg="Only 'aws:kms' is a valid option for encryption parameter when you specify encryption_key_id.")

if state == 'present':
Expand Down

0 comments on commit c977459

Please sign in to comment.