From b41bff88f6209613921ee317f72a182a7a2e9c7f Mon Sep 17 00:00:00 2001 From: Drazen Date: Thu, 23 Jan 2025 16:13:15 +0100 Subject: [PATCH] Updating-aws-ses --- roles/aws/aws_ses/tasks/main.yml | 1 + .../aws_ses/templates/fetch_account_id.py.j2 | 18 ------------------ 2 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 roles/aws/aws_ses/templates/fetch_account_id.py.j2 diff --git a/roles/aws/aws_ses/tasks/main.yml b/roles/aws/aws_ses/tasks/main.yml index ffa4bba50..346c3c476 100644 --- a/roles/aws/aws_ses/tasks/main.yml +++ b/roles/aws/aws_ses/tasks/main.yml @@ -5,6 +5,7 @@ identity: "{{ _ses_domain }}" state: present region: "{{ _aws_region }}" + delegate_to: localhost - name: Gather AWS account ID if it isn't already set. amazon.aws.aws_caller_info: diff --git a/roles/aws/aws_ses/templates/fetch_account_id.py.j2 b/roles/aws/aws_ses/templates/fetch_account_id.py.j2 deleted file mode 100644 index 8de519679..000000000 --- a/roles/aws/aws_ses/templates/fetch_account_id.py.j2 +++ /dev/null @@ -1,18 +0,0 @@ -#!/home/controller/ansible/bin/python3 -import boto3 -import sys -from botocore.exceptions import NoCredentialsError - -def get_account_id(): - try: - session = boto3.Session() - sts_client = session.client('sts') - response = sts_client.get_caller_identity() - return response['Account'] - except NoCredentialsError: - print("Could not find AWS credentials.") - sys.exit(1) - -if __name__ == "__main__": - account_id = get_account_id() - print(account_id)