'How to export variable (s3 bucket name) from bash (YAML) to python file

I have terraform-intgr.yml file which performs terraform init, plan, apply task. Also, I have s3 bucket name in output.tf. terraform steps completed successfully and I can exported s3 bucket name in .yml file. But, I can't access variable 'S3_BUCKET_NAME' from python file. Getting None(no value) for this value in python code.

Can you please assist in how to access s3 bucket name in python code?

output.tf:

output "s3_bucket_name" {
  value = aws_s3_bucket.s3_bucket.id
}

terraform-intgr.yml:

run:
  path: /bin/bash
  args:
    - -excl
    - | # yaml multiline
      ...
      ...
      export S3_BUCKET_NAME=$(terraform output s3_bucket_name)

app.py:

def __init__(self):
        bucket_name = os.environ['S3_BUCKET_NAME']
        print(bucket_name)`


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source