def dms_cloudwatch_logs_role()

in redshift_poc_automation/stacks/dmsinstance_stack.py [0:0]


    def dms_cloudwatch_logs_role(self):
        client = boto3.client('iam')
        try:
            response = client.get_role(RoleName='dms-cloudwatch-logs-role')
        except:
            try:
                role_policy_document = {
                       "Version": "2012-10-17",
                       "Statement": [
                       {
                         "Effect": "Allow",
                         "Principal": {
                            "Service": "dms.amazonaws.com"
                         },
                       "Action": "sts:AssumeRole"
                       }
                    ]
                }
                client.create_role(
                    RoleName='dms-cloudwatch-logs-role',
                    AssumeRolePolicyDocument=json.dumps(role_policy_document)
                )
                client.attach_role_policy(
                    RoleName='dms-cloudwatch-logs-role',
                    PolicyArn='arn:aws:iam::aws:policy/service-role/AmazonDMSCloudWatchLogsRole'
                )
            except Exception as e:
                print(e)