import { InstanceType, IVpc, SubnetSelection } from 'aws-cdk-lib/aws-ec2'; import { LifecyclePolicy, OutOfInfrequentAccessPolicy, PerformanceMode } from 'aws-cdk-lib/aws-efs'; import { IUser } from 'aws-cdk-lib/aws-iam'; import { RetentionDays } from 'aws-cdk-lib/aws-logs'; import { MariaDbEngineVersion, PostgresEngineVersion } from 'aws-cdk-lib/aws-rds'; import { TaskEnvironment } from '../../utilities/environment'; import { ODICPackageConfig } from '../../packages/bitbucket-odic'; /** * The settings provided for the web application service */ export interface WebAppServiceSettings { /** * Define an application name */ name: string; /** * Define the environment (prod, staging) */ env: string; /** * Allows you to define the group that the stack users will * be attached to. This allows you to put the users in an * existing group. */ groupName?: string; /** * Define a user to reuse across multiple services for file * access. Will be created if not set or null */ fileAccessUsername?: string; /** * Allows you to define the service username to reuse a user * across multiple services. Will be created if it doesn't already * exist. */ serviceUserName?: string; /** * Define a region */ region: string; /** * Optionally provide an app key. This might be retrievable from the secrets */ appKey?: string; /** * Pass the ARN of a secret store */ secretsARN: string; /** * VPC will accept either an instance of an IVpc, string vpc id or null. * If null, we'll create a new VPC. If you provide a string, we'll import * that vpc, If you provide an instance, we'll use that if possible or error out */ vpc?: string | IVpc; /** * The db needs subnets defined. Provide these two. */ subnet1?: string; subnet2?: string; /** * Provide a certificate ARN. If you don't provide one, and the dns is hosted at route 53, * the cert will automatically be generated. */ certificate?: string; /** * Provide the web contianer settings */ webContainer: ContainerSettings; /** * Optionally provide a queue container settings for background processing */ queueContainer?: ContainerSettings; /** * Provide smtp settings for the application */ mail: MailSettings; /** * Provide database settings for the application */ database?: WebAppDatabaseSettings; /** * Provide the basic dns settings for the application */ dns: DnsSettings; /** * Allows the settings to provide custom environment vars */ customEnvironment: TaskEnvironment; /** * Provide an array of resolvable environment secrets where * the key is the env var, and the value is the settings key */ customEnvironmentSecrets: TaskEnvironment; /** * Provide a public bucket name */ public_bucket?: string; /** * Provide a private bucket name */ private_bucket?: string; /** * Provide the path to the public image endpoint, either imgix * or a cloud front url */ image_url: string; file_system?: FileSystemSettings | null; } /** * Allows user to provide a efs file system that * will be mounted to the containers */ export interface FileSystemSettings { mountPoint: string | null; lifecyclePolicy?: LifecyclePolicy; performanceMode: PerformanceMode; outOfInfrequentAccessPolicy: OutOfInfrequentAccessPolicy; } /** * We often provide key value pairs. This is the signature for that */ export interface KeyValue { key: string; value: string; } /** * These are the container settings that are defined. */ export interface ContainerSettings { /** * The path to the repository image. The ecr dependency stack will * create this. Optional since ARN is also an option */ image?: string; /** * The ARN of an image. Helpful for using cross region images. * This will take priority over image if this is set */ imageArn?: string; /** * The default tag that this container should pull from */ tag?: string; /** * How many containers are desired */ desired: number; /** * What port should the container listen on? Defaults to 8080 */ containerPort?: number | null; /** * What port does the ELB listen on? Defaults to 443 */ elbPort?: number | null; /** * Should the container be assigned a public IP address? */ assignPublicIp?: boolean; vpcSubnets?: SubnetSelection; /** * The number of cpu units used by the task. * * Valid values, which determines your range of valid values for the memory parameter: * * 256 (.25 vCPU) - Available memory values: 0.5GB, 1GB, 2GB * * 512 (.5 vCPU) - Available memory values: 1GB, 2GB, 3GB, 4GB * * 1024 (1 vCPU) - Available memory values: 2GB, 3GB, 4GB, 5GB, 6GB, 7GB, 8GB * * 2048 (2 vCPU) - Available memory values: Between 4GB and 16GB in 1GB increments * * 4096 (4 vCPU) - Available memory values: Between 8GB and 30GB in 1GB increments * * This default is set in the underlying FargateTaskDefinition construct. * * @default 256 */ cpu: number; /** * The amount (in MiB) of memory used by the task. * * This field is required and you must use one of the following values, which determines your range of valid values * for the cpu parameter: * * 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU) * * 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU) * * 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU) * * Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU) * * Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU) * * This default is set in the underlying FargateTaskDefinition construct. * * @default 512 */ memory: number; /** * How long should we wait */ gracePeriod?: number; /** * The minimum containers to deploy */ min?: number; /** * The maximum containers to deploy */ max?: number; /** * The name of the user that deploys content. This allows you to share * a deploy user between stacks. */ deployUser?: IUser | string; /** * If you want to deploy with ODIC rather than a deploy user, provide the * ODIC settings required here. This will disable the deploy user */ odic?: ODICPackageConfig; /** * How Long should logs be retained for */ logRetention?: RetentionDays; /** * What uri should be checked for container health */ healthPath?: string; } /** * The DNS settings to provision domains and certs if possible */ export interface DnsSettings { /** * Is the domain hosted on route53? */ route53: boolean; /** * What is the hosted zone id? Pass false if this isn't a route53 domain */ zone: string | boolean; /** * Prefix for your url. https://{prefix}.{domain} */ prefix: string; /** * Domain for your url. https://{prefix}.{domain} */ domain: string; } /** * The basic settings for the web database */ export interface WebAppDatabaseSettings { /** * Accepts either pgsql or mysql */ engine: string; /** * Allow the database to be publicly accessible. The goal is to move the database * to a private subnet, but if it must be public, this will allow that */ publiclyAccessible?: boolean; /** * Allow the user to set the version of the database */ pgsql_version?: PostgresEngineVersion; maria_version?: MariaDbEngineVersion; /** * What port to bind to, * @default 5432 */ port?: number; /** * The name of the database */ database: string; /** * The name of the compute and memory capacity for the instance. * * @default - m5.large (or, more specifically, db.m5.large) */ instanceType: InstanceType; /** * Should the database run as a multi az instance */ multiAZ?: boolean; /** * Enable performance insight logging */ enablePerformanceInsights?: boolean; /** * Prevent termination */ deletionProtection?: boolean; } export interface MailSettings { mailer?: string; /** * The smtp hostname */ host: string; /** * The username. If not supplied, it will be pulled from the secrets */ username?: string; /** * Password (pull from a secret). If not supplied, it will be pulled * from the secrete */ password?: string; /** * Port to send mail to */ port: number; /** * The email address to send from */ from: string; } export default WebAppServiceSettings;