- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use Boto3 to get the security configuration/encryption settings of a catalog from AWS Glue Data Catalog?
Problem Statement − Use boto3 library in Python to retrieve the security configuration/encryption settings of a catalog.
Example − Retrieve the security configuration/encryption settings of a catalog.
Approach/Algorithm to solve this problem
Step 1 − Import boto3 and botocore exceptions to handle exceptions.
Step 2 − catalog_id is the optional parameter. If it is not provided, it takes the detail of user’s AWS account.
Step 3 − Create an AWS session using boto3 library. Make sure region_name is mentioned in default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.
Step 4 − Create an AWS client for glue.
Step 5 − Now use get_data_catalog_encryption_settings function and pass the catalog_id as CatalogId parameter.
Step 6 − It returns the details of encryption settings.
Step 7 − Handle the generic exception if something went wrong while checking the job.
Example
Use the following code to retrieve security configuration/encryption settings of a catalog −
import boto3 from botocore.exceptions import ClientError def retrieves_encryption_setting(catalog_id=None) session = boto3.session.Session() glue_client = session.client('glue') try: response = glue_client.get_data_catalog_encryption_settings(CatalogId = catalog_id) return response except ClientError as e: raise Exception("boto3 client error in retrieves_encryption_setting: " + e.__str__()) except Exception as e: raise Exception("Unexpected error in retrieves_encryption_setting: " + e.__str__()) print(retrieves_encryption_setting())
Output
{'DataCatalogEncryptionSettings': {'EncryptionAtRest': {'CatalogEncryptionMode': 'SSE-KMS'}, 'ConnectionPasswordEncryption': {'ReturnConnectionPasswordEncrypted': True}}, 'ResponseMetadata': {'RequestId': '5ffc0dbb***************7c', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Sun, 28 Feb 2021 12:22:16 GMT', 'content-type': 'application/x-amz-json-1.1', 'content-length': '166', 'connection': 'keep-alive', 'x-amzn-requestid': '5ffc0dbb********************7c'}, 'RetryAttempts': 0}}
- Related Articles
- How to use Boto3 to get the details of a classifier from AWS Glue Data catalog?
- How to use Boto3 to get the details of a connection from AWS Glue Data catalog?
- How to use Boto3 to get the details of a database from AWS Glue Data Catalog?
- How to use Boto3 to delete a crawler from AWS Glue Data Catalog?
- How to use Boto3 to delete a table from AWS Glue Data catalog?
- How to use Boto3 to get the table definition of a database from AWS Glue Data Catalog?
- How to use Boto3 get the details of all the databases from AWS Glue Data Catalog?
- How to use Boto3 to get the metrics of one/manyspecified crawler from AWS Glue Data Catalog?
- How to get the details of a trigger from AWS Glue Data catalog using Boto3
- How to use Boto3 to start a crawler in AWS Glue Data Catalog
- How to use Boto3 to start a trigger in AWS Glue Data Catalog
- How to use Boto3 to stop a trigger in AWS Glue Data Catalog
- How to use Boto3 to start a workflow in AWS Glue Data Catalog
- How to use Boto3 to stop a workflow in AWS Glue Data Catalog
- How to use Boto3 to stop a crawler in AWS Glue Data Catalog
