apiVersion: xl/v2
kind: Blueprint

metadata:
  name: AWS-Datalake
  description: |
    The blueprint deploys a data lake architecture to AWS using CloudFormation.
    XL Deploy does the provisioning and deployment, while XL Release orchestrates everything.
    Refer to https://docs.aws.amazon.com/solutions/latest/data-lake-solution
  author: XebiaLabs
  version: 2.0
  instructions: Please read the generated file "xebialabs/USAGE.md" for further usage instructions.
  
spec:
  parameters:
  - name: S3BucketName
    type: Input
    prompt: What is the name of the S3 bucket where CloudFormation templates should be saved?
    default: data-lake
    validate: !expr "regex('^(([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9]){3,63}$', S3BucketName)"
  - name: AdministratorName
    type: Input
    prompt: What is the name of the Data Lake administrator user?
    default: admin
    validate: !expr "regex('^.+$', AdministratorName)"
  - name: AdministratorEmail
    prompt: "Provide a valid email address where to send the generated Data Lake administrator credentials:"
    type: Input
    validate: !expr "regex('^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$', AdministratorEmail)"
  - name: CognitoDomain
    prompt: "Provide a name for the Cognito service domain (can only contain lower-case letters, numbers, and hyphens):"
    default: data-lake
    type: Input
    validate: !expr "regex('^[a-z0-9-]+$', CognitoDomain)"
  - name: UseAWSCredentialsFromSystem
    type: Confirm
    prompt: Do you want to use AWS credentials from ~/.aws/credentials file?
    promptIf: !expr "awsCredentials('IsAvailable')"
  - name: AWSAccessKey
    type: SecretInput
    prompt: What is the AWS Access Key ID?
    promptIf: !expr "!UseAWSCredentialsFromSystem"
    default: !expr "awsCredentials('AccessKeyID')"
  - name: AWSAccessSecret
    type: SecretInput
    prompt: What is the AWS Secret Access Key?
    promptIf: !expr "!UseAWSCredentialsFromSystem"
    default: !expr "awsCredentials('SecretAccessKey')"
  - name: AWSRegion
    type: Select
    saveInXlvals: true
    prompt: "Select the AWS region:"
    default: us-east-2
    options:
      - label: US West (Oregon)
        value: us-west-2
      - label: US East (N. Virginia)
        value: us-east-1
      - label: US East (Ohio)
        value: us-east-2
      - label: EU (Frankfurt)
        value: eu-central-1
      - label: EU (Ireland)
        value: eu-west-1
      - label: EU (London)
        value: eu-west-2
      - label: Canada (Central)
        value: ca-central-1
      - label: Asia Pacific (Tokyo)
        value: ap-northeast-1
      - label: Asia Pacific (Seoul)
        value: ap-northeast-2
      - label: Asia Pacific (Mumbai)
        value: ap-south-1
      - label: Asia Pacific (Singapore)
        value: ap-southeast-1
      - label: Asia Pacific (Sydney)
        value: ap-southeast-2

  - name: GenerateDockerComposeSetup
    type: Confirm
    prompt: "Do you want to generate a docker-compose setup with the required tools to run this blueprint?"
    default: false

  includeAfter:
  - blueprint: xl-devops-platform
    includeIf: GenerateDockerComposeSetup
    parameterOverrides:
    - name: UseXLDeploy
      value: true
    - name: XLDeployPort
      value: 4516
    - name: UseXLRelease
      value: true
    - name: XLReleasePort
      value: 5516
    - name: JetPackOrEnterprise
      value: "XL Enterprise"
    - name: XLVersion
      value: "9.0.0"
    - name: UseDockerProxy
      value: false
    - name: UseJenkins
      value: false

  files:
  - path: xebialabs.yaml
  - path: cloudformation/data-lake-artifacts.zip
  - path: cloudformation/data-lake-api.yaml
  - path: cloudformation/data-lake-services.yaml
  - path: cloudformation/data-lake-storage.yaml
  - path: cloudformation/data-lake-deploy-federated.master.yaml.tmpl
  - path: cloudformation/data-lake-deploy.master.yaml.tmpl
  - path: xebialabs/USAGE.md.tmpl
  - path: xebialabs/xld-infrastructure.yaml.tmpl
  - path: xebialabs/xld-environment.yaml.tmpl
  - path: xebialabs/xlr-pipeline.yaml.tmpl
