Cole Murray
05/07/2022, 3:53 AMorionServer.addContainer('ServiceContainer', {
essential: true,
image: ContainerImage.fromDockerImageAsset(serviceImage),
logging: new AwsLogDriver({
streamPrefix: 'orion-server'
}),
portMappings: [{
containerPort: this.props.orionEnvVars?.port || Number(this.CONTAINER_PORT)
}],
environment: {
PREFECT_ORION_API_HOST: this.props.orionEnvVars?.host || '0.0.0.0',
PREFECT_ORION_API_PORT: this.props.orionEnvVars?.port?.toString() || this.CONTAINER_PORT,
PREFECT_ORION_DATABASE_CONNECTION_URL: `postgres+asyncpg:///${this.props.username}:${ecsSecret.fromSecretsManager(this.props.dbPassword)}@${this.props.databaseHost}/orion`
},
secrets: {
},
memoryLimitMiB: 300,
});
We can overcome this by altering the settings provided, and fetching the username and password separately from the host to build the DB URI, perhaps as a second set of options.
Has anyone found an alternate way to concat the strings together? If not, are we open to adding additional options to distinguish DB_PASSWORD to be injected as secrets?PREFECT_ORION_DATABASE_PASSWORD = Setting(
str,
default="",
description=textwrap.dedent(
"""
Password of the orion database. Intended to be used with string templating in database connection url.
Usage: postgres+asyncpg:///postgres:${PREFECT_ORION_DATABASE_PASSWORD}@localhost/orion
"""
)
)
PREFECT_ORION_DATABASE_CONNECTION_URL = Setting(
str,
default="sqlite+aiosqlite:////${PREFECT_HOME}/orion.db",
description=textwrap.dedent(
f"""
A database connection URL in a SQLAlchemy-compatible
format. Orion currently supports SQLite and Postgres. Note that all
Orion engines must use an async driver - for SQLite, use
`sqlite+aiosqlite` and for Postgres use `postgresql+asyncpg`.
SQLite in-memory databases can be used by providing the url
`sqlite+aiosqlite:///file::memory:?cache=shared&uri=true&check_same_thread=false`,
which will allow the database to be accessed by multiple threads. Note
that in-memory databases can not be accessed from multiple processes and
should only be used for simple tests.
Defaults to a sqlite database stored in the Prefect home directory.
"""
),
value_callback=template_with_settings(PREFECT_HOME, PREFECT_ORION_DATABASE_PASSWORD),
)
Anna Geller
Cole Murray
05/08/2022, 12:34 AM