I'm migrating from on premises airflow to amazon MWAA 2.0.2. Currently I'm using an s3 connection which contains the access key id and secret key for s3 operations:
{
"conn_id" = "s3_default"
"conn_type" : "S3"
"extra" = {
"aws_access_key_id" = "aws_access_key_id"
"aws_secret_access_key" = "aws_secret_access_key"
}
}
I create a hook from airflow.providers.amazon.aws.hooks.s3
which implementing airflow.providers.amazon.aws.hooks.base_aws
to interact with s3:
hook = S3Hook(conn_id=self.s3_default)
Everything is fine. But because I'm moving to MWAA I assume I don't need to handle s3 access using AWS keys. I understand that my tasks running inside ECS containers and the MWAA execution role should be enough (given the proper s3 IAM permissions are provided in the role) for boto3 to interact with s3 in this case. So What I did I removed the connection Id from the hook and deleted the airflow connection:
hook = S3Hook()
So according the AwsBaseHook
documentation if the aws_conn_id
is None or empty then the default boto3 behavior is used. However it is not working and I am getting access denied error:
Does anybody know if even this possible to connect to aws services from MWAA without an explicit connection and only permissions in the execution role?