Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import os 

2from abc import ABCMeta, abstractmethod 

3import boto3 

4import logging 

5 

6from sdc_etl_libs.hashicorp_helpers.vault import Vault 

7 

8if len(logging.getLogger().handlers) > 0: 

9 logging.getLogger().setLevel(logging.INFO) 

10else: 

11 logging.basicConfig( 

12 level=logging.INFO, 

13 format="%(levelname)s: %(asctime)s: %(funcName)s: %(message)s", 

14 ) 

15 

16 

17class PGP(metaclass=ABCMeta): 

18 

19 def __init__(self): 

20 

21 sts = boto3.client('sts') 

22 resp = sts.get_caller_identity() 

23 role_ = f"arn:aws:iam::{resp.get('Account')}:role/{resp.get('Arn').split('/')[1]}" 

24 logging.info("Current IAM role: {}".format(role_)) 

25 

26 self.vault = Vault() 

27 

28 @abstractmethod 

29 def create_keys(self): 

30 raise Exception("Do not use base class implementation of create keys.") 

31 

32 @abstractmethod 

33 def encrypt(self): 

34 raise Exception("Do not use base class implementation of encrypt.") 

35 

36 @abstractmethod 

37 def decrypt(self): 

38 raise Exception("Do not use base class implementation of decrypt.")