Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint_management attribute #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mbtiii
Copy link

@mbtiii mbtiii commented Jul 12, 2024

What does this PR do?

  • Added support for the endpoint_management attribute on MWAA environments.
    • This allows you to create MWAA environments inside VPCs that are owned by other accounts, as long as you manually create the VPC endpoints required by Airflow.
  • Bumped up the AWS provider requirements to the earliest version that supports the new attribute

Motivation

We wanted to migrate our Airflow clusters, which were created with this module, to a shared VPC.

Relevant issue: #58

More

  • Yes, I have tested the PR using my local account setup (Provide any test evidence report under Additional Notes)
  • Yes, I ran pre-commit run -a with this PR
    • It failed, but for the same reasons that already existed before this PR (i.e., problems with the examples/basic code)

For Moderators

  • E2E Test successfully complete before merge?

Additional Notes

  • When deploying an environment with endpoint_management="CUSTOMER", the cluster creation will hang until you've created the endpoint yourself. If it times out, you may need to terraform untaint the cluster after it's finished being created. This is a deficiency in the resource itself.
  • Creating the endpoint via Terraform is not easy since the AWS provider does not have a data element for aws_mwaa_environment, and the attributes are not available via the resource until after it has been created.

Evidence of Deployment

Note that many values have been redacted for our own security:

> tf state show module.mwaa.aws_mwaa_environment.mwaa
# module.mwaa.aws_mwaa_environment.mwaa:
resource "aws_mwaa_environment" "mwaa" {
    airflow_configuration_options   = (sensitive value)
    airflow_version                 = "2.7.2"
    arn                             = "arn:aws:airflow:XXXXXX:XXXXXXXXXXXX:environment/XXXXXX"
    created_at                      = "2024-07-10 17:54:17 +0000 UTC"
    dag_s3_path                     = "dags/"
    endpoint_management             = "CUSTOMER" <------ This is the attribute I added
    environment_class               = "mw1.small"
    execution_role_arn              = "arn:aws:iam::XXXXXXXXXXXX:role/XXXXXX"
    id                              = "XXXXXX"
    last_updated                    = [
        {
            created_at = "2024-07-10 17:54:17 +0000 UTC"
            error      = []
            status     = "SUCCESS"
        },
    ]
    max_workers                     = 3
    min_workers                     = 3
    name                            = "XXXXXX"
    plugins_s3_object_version       = "XXXXXX"
    plugins_s3_path                 = "plugins/plugins.zip"
    requirements_s3_object_version  = "XXXXXX"
    requirements_s3_path            = "requirements/requirements.txt"
    schedulers                      = 2
    service_role_arn                = "arn:aws:iam::XXXXXXXXXXXX:role/aws-service-role/airflow.amazonaws.com/AWSServiceRoleForAmazonMWAA"
    source_bucket_arn               = "arn:aws:s3:::XXXXXX"
    status                          = "AVAILABLE"
    tags                            = {}
    tags_all                        = {
        ...
    }
    webserver_access_mode           = "PUBLIC_ONLY"
    webserver_url                   = "XXXXXX.XXXXXX.XXXXXX.airflow.amazonaws.com"
    weekly_maintenance_window_start = "MON:07:30"

    logging_configuration {
        ...
    }

    network_configuration {
        security_group_ids = [
            "sg-XXXXXX",
        ]
        subnet_ids         = [
            "subnet-XXXXXX", <------ These subnets do not belong to the account
            "subnet-XXXXXX",
        ]
    }
}

@mbtiii mbtiii requested review from vara-bonthu and a team as code owners July 12, 2024 17:29
@mbtiii mbtiii changed the title Add endpoint_management attribute (#1) Add endpoint_management attribute Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant