Parameters: EcsClusterName: Type: String Default: "" Description: The name with which to create the ECS cluster (defaults to -ecs-cluster-db-init if not provided). EcsTaskExecutionRoleArn: Type: String Description: The ARN for the ECS task execution role LambdaRoleArn: Type: String Description: The ARN for lambda role NodesSubnet1Id: Type: String Description: The id of the first subnet NodesSubnet2Id: Type: String Description: The id of the second subnet LambdaSecurityGroupId: Type: String Description: The Id of the Lambda security group DatabaseEndpoint: Type: String Description: The endpoint of the database DatabaseAdminUsername: Type: String Description: The database admin username for the database DatabaseAdminPassword: Type: String Description: The database admin password for the database NoEcho: true BseeAdminRepositoryUsername: Type: String Description: The database username for enterprise server BseeAdminRepositoryPassword: Type: String Description: The database password for enterprise server NoEcho: true BseeAgentRepositoryUsername: Type: String Description: The database username for agents BseeAgentRepositoryPassword: Type: String Description: The database password for agents NoEcho: true Conditions: EcsClusterNameProvided: !Not [!Equals [!Ref EcsClusterName, ""]] Resources: EcsClusterDbInit: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://bsee-cloud.s3-eu-west-1.amazonaws.com/2021.8.1-7685/ecs-cluster.yaml Parameters: Name: !If - EcsClusterNameProvided - !Ref EcsClusterName - !Sub ${AWS::StackName}-ecs-cluster-db-init DbLogGroup: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://bsee-cloud.s3-eu-west-1.amazonaws.com/2021.8.1-7685/logs-loggroup.yaml Parameters: LogGroupPrefix: /aws/ecs/containerinsights LogGroupId: !GetAtt EcsClusterDbInit.Outputs.Id LogGroupSuffix: db-init DbInitTaskDefinition: Type: AWS::ECS::TaskDefinition Properties: ContainerDefinitions: - Environment: - Name: DB_SERVER Value: !Ref DatabaseEndpoint - Name: PGUSER Value: !Ref DatabaseAdminUsername - Name: PGPASSWORD Value: !Ref DatabaseAdminPassword - Name: BSEE_DB_NAME Value: burp_enterprise - Name: BSEE_AGENT_REPOSITORY_USERNAME Value: !Ref BseeAgentRepositoryUsername - Name: BSEE_AGENT_REPOSITORY_PASSWORD Value: !Ref BseeAgentRepositoryPassword - Name: BSEE_ADMIN_REPOSITORY_USERNAME Value: !Ref BseeAdminRepositoryUsername - Name: BSEE_ADMIN_REPOSITORY_PASSWORD Value: !Ref BseeAdminRepositoryPassword Image: portswigger/enterprise-postgres-init:4 Name: bsee-enterprise-db-init LogConfiguration: LogDriver: awslogs Options: awslogs-region: !Sub ${AWS::Region} awslogs-group: !GetAtt DbLogGroup.Outputs.Id awslogs-stream-prefix: !Sub ${AWS::StackName} Cpu: 256 ExecutionRoleArn: !Ref EcsTaskExecutionRoleArn Memory: 512 NetworkMode: awsvpc RequiresCompatibilities: - FARGATE Tags: - Key: Name Value: !GetAtt EcsClusterDbInit.Outputs.Id DbInitLambda: Type: AWS::CloudFormation::Stack Properties: TemplateURL: https://bsee-cloud.s3-eu-west-1.amazonaws.com/2021.8.1-7685/lambda-function.yaml Parameters: NodesSubnet1Id: !Ref NodesSubnet1Id NodesSubnet2Id: !Ref NodesSubnet2Id LambdaSecurityGroupId: !Ref LambdaSecurityGroupId LambdaRoleArn: !Ref LambdaRoleArn DatabaseInit: Type: AWS::CloudFormation::CustomResource Properties: ServiceToken: !GetAtt DbInitLambda.Outputs.Arn ClusterId: !GetAtt EcsClusterDbInit.Outputs.Id TaskDefinition: !Ref DbInitTaskDefinition Subnets: - !Ref NodesSubnet1Id - !Ref NodesSubnet2Id SecurityGroups: - !Ref LambdaSecurityGroupId