thedataengineer
thedataengineer

Reputation: 169

How can I Update AWS Glue Database

Hi I have one task where I have to update Glue database owner name from xyz to abc/abc2 for 2 days I am struggling with this issue following the below guide but not able to understand can anyone share python code for updating the database (I am a novice in python )

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/glue.html

import boto3

client = boto3.client('glue')
response = client.update_database(
    CatalogId='None',
    Name='AviralDB',
    DatabaseInput={
        'Name': 'AviralDB',
        'Description': 'For testing purpose ',
        'LocationUri': 's3a://mybucket/',
        'Parameters': {
            'owner': 'aviralb'
        },
        'CreateTableDefaultPermissions': [
            {
                'Principal': {
                    'DataLakePrincipalIdentifier': 'string'
                },
                'Permissions': [
                    'ALL'|'SELECT'|'ALTER'|'DROP'|'DELETE'|'INSERT'|'CREATE_DATABASE'|'CREATE_TABLE'|'DATA_LOCATION_ACCESS',
                ]
            },
        ],
        'TargetDatabase': {
            'CatalogId': 'None',
            'DatabaseName': 'AviralDB'
        }
    }
)

What exactly I have to write here ?? Please help I want to update my glue database owner only

Upvotes: 1

Views: 529

Answers (1)

Prabhakar Reddy
Prabhakar Reddy

Reputation: 5144

I was able to update my existing database properties by passing owner to parameters as shown in below snippet. You can use below example to do the same.

response = client.update_database(
    
    Name='testing',
    DatabaseInput={
        'Name': 'testing',
        'Description': 'testing change',
        'LocationUri': 's3://glue-poc/test',
        'Parameters': {
            'owner': 'guru'
        },
        'CreateTableDefaultPermissions': [
            {
                'Principal': {
                    'DataLakePrincipalIdentifier': 'IAM_ALLOWED_PRINCIPALS'
                },
                'Permissions': ['ALL']
            },
        ]
    }
)

Upvotes: 1

Related Questions