Skip to content

Commit

Permalink
Use public subnets, assign public IP for ECSRunTask network config
Browse files Browse the repository at this point in the history
  • Loading branch information
amywieliczka committed Oct 11, 2024
1 parent 9f08eb5 commit a46d483
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dags/shared_tasks/content_harvest_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@

def get_awsvpc_config():
"""
get private subnets and security group from cloudformation stack for use
get public subnets and security group from cloudformation stack for use
with the ContentHarvestEcsOperator to run tasks in an ECS cluster
"""
client = boto3.client('cloudformation', region_name='us-west-2')
awsvpcConfig = {
"subnets": [],
"securityGroups": []
"securityGroups": [],
"assignPublicIp": "ENABLED"
}
cf_outputs = (client
.describe_stacks(StackName='pad-airflow-mwaa')
.get('Stacks', [{}])[0]
.get('Outputs', [])
)
for output in cf_outputs:
if output['OutputKey'] in ['PrivateSubnet1', 'PrivateSubnet2']:
if output['OutputKey'] in ['PublicSubnet1', 'PublicSubnet2']:
awsvpcConfig['subnets'].append(output['OutputValue'])
if output['OutputKey'] == 'SecurityGroup':
awsvpcConfig['securityGroups'].append(output['OutputValue'])
Expand Down

0 comments on commit a46d483

Please sign in to comment.