<#3036 Add new 'inventory' top-level key to regist...
# meltano-repo-activity
g
#3036 Add new 'inventory' top-level key to register 'resources' Issue created by MeltyBot Migrated from GitLab: https://gitlab.com/meltano/meltano/-/issues/3108 Originally created by @kgpayne on 2021-12-08 140216 --- tldr; 'Inventory' is akin to sources in the dbt world - representations of entities that exist (and can be used in the dbt project context) but are not directly managed by dbt. Problem to solve During the deployment of base infrastructure for Meltano to use (using Infrastructure as Code), resources are created that will commonly be referenced by other tools in the Meltano ecosystem (el, dbt, etc.). Today this handoff needs to be done manually - database, warehouse, S3/object storage buckets etc. are all added to
meltano.yml
as static config and in various formats (e.g. URI vs. separate username, password, database). By introducing a first class 'resource' representation in Meltano that can i) be managed using the CLI/in
meltano.yml
and ii) be referenced by its alias/id within Meltano (environments, tap/target configs etc.) we provide a way for tools like Terraform to 'hand-off' resource details (including secrets) to Meltano, and for those details to change (if necessary) without breaking existing references within the Meltano Project (as resources are referenced by their alias/id rather than by hard-coded attributes, servicing use-cases like automated password rotation). Proposal • A yaml spec for 'resources' under a top-level 'inventory' key. • CLI additions to manage resources (and secrets), accepting inputs in JSON (on the basis that Terraform can format its output in these formats). Note: the reference syntax below (e.g.
"{{ .inv... }}"
) is very much up for debate. We may need to follow the Jinja macro style if we use that engine for templating/referencing. The ones shown are Helm style, which I believe uses the templating language built in to Golang. # Example definition inventory: - id: prod-meltano-database type: database_postgres properties: host: "<hostname>" port: "<port>" username: "<user name>" password: "<default password>" # ideally this would be a ref to a secret value added separately database: "<optional: default database>" schema: "<optional: default schema>" uri: "<optional: sqlalchemy uri>" # this can maybe be inferred - id: prod-s3-bucket type: aws_s3_bucket properties: name: "<s3 bucket name>" prefix: "<optional: default prefix>" profile: "<optional: aws profile name>" aws_access_key_id: "<optional: aws access key id>" # ideally this would be a ref to a secret value added separately aws_secret_access_key: "<optional: aws secret access key>" # ideally this would be a ref to a secret value added separately - id: prod-snowflake-load type: snowflake_warehouse properties: account: "<snowflake account name>" database: "<snowflake database name>" region: "<warehouse region>" warehouse: "<snowflake warehouse name>" username: "<user name>" password: "<password>" # ideally this would be a ref to a secret value added separately role: "<snowflake role>" session_parameters: "<session level parameters>" # Example usage environments: - name: prod config: plugins: loaders: - name: target-snowflake config: db_name: "{{ .inv.prod-snowflake-load.database }}" # References resources defined above account: "{{ .inv.prod-snowflake-load.account }}" user: "{{ .inv.prod-snowflake-load.username }}" role: "{{ .inv.prod-snowflake-load.username }}" load_schema: "${TAP_NAMESPACE}_raw" # Dynamic from the name of the currently-executing tap In Terraform, resources may be defined using the same schema as above as regular
output
blocks: output "meltano" { value = [ { id = "prod-meltano-database" type = "database_postgres" properties = { host = module.db.db_instance_endpoint port = module.db.db_instance_port user = module.db.db_instance_username password = { type = "secret" value = module.db.db_instance_password } database = module.db.db_instance_name } } ] } The user experience might be: # make changes to infrastructure terraform apply # output 'meltano' output name to file 'resources.json' terraform output -json meltano > resources.json # read 'resources.json' meltano config inventory update -file resources.json Or, eventually: meltano invoke -update-resources terraform apply meltano/meltano