Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cognito ¶
type Cognito struct {
UseLocal bool `env:"COGNITO_USE_LOCAL" yaml:"cognitoUseLocal" envDefault:"false" safe:"true"`
Endpoint string `env:"COGNITO_ENDPOINT" yaml:"cognitoEndpoint" safe:"true"`
ClientId string `env:"COGNITO_CLIENT_ID" json:"cognitoClientId" yaml:"cognitoClientId"`
UserPoolId string `env:"COGNITO_USER_POOL_ID" json:"cognitoUserPoolId" yaml:"cognitoUserPoolId"`
IssuerUrl string `env:"COGNITO_ISSUER_URL" yaml:"cognitoIssuerUrl"`
// This will need to be set by the user as it will be dependent on your setup. For example, you might have multiple
// callback urls that are valid, but if you are running against a live, prelive, or local environment the redirect
// will be different. Therefore, this is not set by the terraform module itself, but instead should be added by the
// user.
RedirectUrl string `env:"COGNITO_REDIRECT_URL" yaml:"cognitoRedirectUrl"`
}
Cognito Struct meant to wrap configuration values to work alongside the https://github.com/project-init/terraform-aws-cognito terraform module. Usage would look similar to
type Config struct {
// Cognito
CognitoConfig cfg.CognitoConfig `env:"COGNITO" yaml:"cognito" safe:"true"`
}
var (
configuration *Config = &Config{}
once sync.Once
)
func GetConfig() *Config {
once.Do(func() {
opts := []cfg.Option{}
if configFiles, ok := os.LookupEnv(EnvVarConfigFiles); ok && len(configFiles) > 0 {
opts = append(opts, cfg.NewFileOption(configFiles))
}
if smSecrets, ok := os.LookupEnv(EnvVarConfigAWSSecretsManagerSecrets); ok && len(smSecrets) > 0 {
opts = append(opts, cfg.NewAWSSecretsManagerOption(secretsmanager.NewFromConfig(aws.GetConfig()), strings.Split(smSecrets, ",")...))
}
opts = append(opts, cfg.NewEnvOption())
if err := cfg.LoadConfigs(configuration, opts...); err != nil {
sre.LogFatal(err)
}
})
return configuration
}
type RDS ¶ added in v0.3.1
type RDS struct {
PostgresDatabase string `env:"POSTGRES_DATABASE" yaml:"postgresDatabase" safe:"true"`
PostgresPort string `env:"POSTGRES_PORT" yaml:"postgresPort" safe:"true"`
PostgresReadOnlyHost string `env:"POSTGRES_READ_ONLY_HOST" yaml:"postgresReadOnlyHost" safe:"true"`
PostgresReadOnlyUser string `env:"POSTGRES_READ_ONLY_USER" yaml:"postgresReadOnlyUser" safe:"true"`
PostgresReadOnlyPassword string `env:"POSTGRES_READ_ONLY_PASSWORD" yaml:"postgresReadOnlyPassword"`
PostgresWriterHost string `env:"POSTGRES_WRITER_HOST" yaml:"postgresWriterHost" safe:"true"`
PostgresWriterUser string `env:"POSTGRES_WRITER_USER" yaml:"postgresWriterUser" safe:"true"`
PostgresWriterPassword string `env:"POSTGRES_WRITER_PASSWORD" yaml:"postgresWriterPassword"`
}
type Service ¶
type Service struct {
Env env.Env `env:"ENV" yaml:"env" safe:"true"`
Region string `env:"AWS_REGION" yaml:"region" safe:"true"`
Version string `env:"VERSION" yaml:"version" safe:"true"`
}
Service Struct meant to wrap configuration values to work alongside service modules from project-init
* https://github.com/project-init/terraform-aws-api-service * https://github.com/project-init/terraform-aws-cron * https://github.com/project-init/terraform-aws-grpc-service
Usage would look similar to
type Config struct {
// Service
ServiceConfig cfg.ServiceConfig `yaml:"service" safe:"true"`
}
var (
configuration *Config = &Config{}
once sync.Once
)
func GetConfig() *Config {
once.Do(func() {
opts := []cfg.Option{}
if configFiles, ok := os.LookupEnv(EnvVarConfigFiles); ok && len(configFiles) > 0 {
opts = append(opts, cfg.NewFileOption(configFiles))
}
if smSecrets, ok := os.LookupEnv(EnvVarConfigAWSSecretsManagerSecrets); ok && len(smSecrets) > 0 {
opts = append(opts, cfg.NewAWSSecretsManagerOption(secretsmanager.NewFromConfig(aws.GetConfig()), strings.Split(smSecrets, ",")...))
}
opts = append(opts, cfg.NewEnvOption())
if err := cfg.LoadConfigs(configuration, opts...); err != nil {
sre.LogFatal(err)
}
})
return configuration
}