How to use Boto3 to get the details of allsecurity configuration present in AWS Glue Security?

Problem Statement − Use boto3 library in Python to get details of all security configuration present in AWS Glue Security.

Example − Get the details of all security configuration present in AWS Glue Security.

Approach/Algorithm to solve this problem

Step 1 − Import boto3 and botocore exceptions to handle exceptions.

Step 2 − There is no parameter. It fetches all security configuration present in user’s AWS Glue Security.

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

Step 6 − It returns the configuration of all security.

Step 7 − Handle the generic exception if something went wrong while checking the job.


Use the following code to fetch configuration of all security −

import boto3
from botocore.exceptions import ClientError

def get_all_security_configuration():
   session = boto3.session.Session()
   glue_client = session.client('glue')
      response = glue_client.get_security_configurations()
      return response
   except ClientError as e:
      raise Exception("boto3 client error in get_all_security_configuration: " + e.__str__())
   except Exception as e:
      raise Exception("Unexpected error in get_all_security_configuration: " + e.__str__())


{'SecurityConfiguration': {'Name': 'job-security-settings',
'CreatedTimeStamp': datetime.datetime(2020, 9, 24, 1, 53, 21, 265000,
tzinfo=tzlocal()), 'EncryptionConfiguration': {'S3Encryption':
[{'S3EncryptionMode': 'SSE-KMS', 'KmsKeyArn': 'arn:aws:kms:us-east1:**************:key/************-bd27-f3ec3b590d0f'}]}},
'ResponseMetadata': {'RequestId': 'b1***************-afd048ed7d07',
'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Mon, 01 Mar 2021
05:48:47 GMT', 'content-type': 'application/x-amz-json-1.1', 'contentlength': '417', 'connection': 'keep-alive', 'x-amzn-requestid':
'b1*******************-afd048ed7d07'}, 'RetryAttempts': 0}}

Updated on: 23-Mar-2021


Kickstart Your Career

Get certified by completing the course

Get Started