<reponame>qodirovshohijahon/python-scripting
#!/usr/bin/env python3

# get acoount authorization detailsusing boto3 and aws-shell (aws-cli)

import boto3
import json
import sys
import os
import pprint

# declare env var for aws-shell

# AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
# AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"]

# print(AWS_ACCESS_KEY_ID)

import boto3

session = boto3.Session(profile_name='k8s-user')
client = boto3.client('kms',
                      aws_access_key_id=' ', 
                      aws_secret_access_key='  ', 
                      region_name='eu-central-1')

# response = client.list_keys()

# print(response)
def create_cmk(description="demo-second-kms", alias="demo-second-kms"):
    kms_client = boto3.client('kms',
                      aws_access_key_id=' ', 
                      aws_secret_access_key='  ', 
                      region_name='eu-central-1')

    response = kms_client.create_key(Description=description)

    # Return the key ID and ARN
    return response["KeyMetadata"]["KeyId"], response["KeyMetadata"]["Arn"]

# create_cmk()

response = client.list_keys()
# print(response['Keys'])
for keys in response['Keys']:
    print(json.dumps(keys, indent=4, sort_keys=True))
#!/usr/bin/env python3

# get acoount authorization detailsusing boto3 and aws-shell (aws-cli)

import boto3
import json
import sys
import os
import pprint

# declare env var for aws-shell

# AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
# AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"]

# print(AWS_ACCESS_KEY_ID)

import boto3

session = boto3.Session(profile_name='k8s-user')
client = boto3.client('kms',
                      aws_access_key_id=' ', 
                      aws_secret_access_key='  ', 
                      region_name='eu-central-1')

# response = client.list_keys()

# print(response)
def create_cmk(description="demo-second-kms", alias="demo-second-kms"):
    kms_client = boto3.client('kms',
                      aws_access_key_id=' ', 
                      aws_secret_access_key='  ', 
                      region_name='eu-central-1')

    response = kms_client.create_key(Description=description)

    # Return the key ID and ARN
    return response["KeyMetadata"]["KeyId"], response["KeyMetadata"]["Arn"]

# create_cmk()

response = client.list_keys()
# print(response['Keys'])
for keys in response['Keys']:
    print(json.dumps(keys, indent=4, sort_keys=True))
#!/usr/bin/env python3 # get acoount authorization detailsusing boto3 and aws-shell (aws-cli) # declare env var for aws-shell # AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"] # AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"] # print(AWS_ACCESS_KEY_ID) # response = client.list_keys() # print(response) # Return the key ID and ARN # create_cmk() # print(response['Keys'])