apiVersion: xl/v2
kind: Blueprint

metadata:
  name: AWS-Elastic-Beanstalk-Sample
  description: |
    This blueprint deploys a sample AWS Elastic Beanstalk PHP5 application.
  author: XebiaLabs
  version: 2.0
  instructions: Please read the generated file "xebialabs/USAGE-elastic-beanstalk.md" for further usage instructions.

spec:
  parameters:
  - 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
    prompt: "Select the AWS region:"
    saveInXlvals: true
    default: !expr "awsRegions('elasticbeanstalk', 0)"
    options:
    - !expr "awsRegions('elasticbeanstalk')"

  - name: AppName
    type: Input
    prompt:  What do you want to name the application? (16 characters max)
    description: Application name will be used to generate cloud resource names
    validate: !expr "regex('^[a-zA-Z][\\\\w-]{1,24}[\\\\w]$', AppName)"

  - name: S3BucketName
    type: Input
    prompt: What is the name of the S3 bucket where CloudFormation artifacts should be saved?
    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)"
    default: !expr "AppName + '-beanstalk-sample'"

  - name: SolutionStackName
    type: Input
    prompt: Enter a Beanstalk Solution Stack Name
    description: If the blueprint fails, it may be because this value is out of date. In that case, enter a more recent one from https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html
    default: "64bit Amazon Linux 2018.03 v2.9.4 running Python 3.6"

  - name: S3Key
    value: "python-app-v1.zip"

  includeAfter:
  - blueprint: xl-devops-platform
    parameterOverrides:
    - name: UseXLDeploy
      value: true
    - name: UseXLRelease
      value: true
    - name: XLVersion
      value: "9.0"
    - name: UseDockerProxy
      value: false
    - name: UseJenkins
      value: false

  files:
  # XebiaLabs
  - path: xebialabs.yaml
  - path: README.md
  - path: xebialabs/USAGE-elastic-beanstalk.md.tmpl
  - path: xebialabs/xld-elastic-beanstalk-applications.yaml.tmpl
  - path: xebialabs/xld-elastic-beanstalk-infrastructure.yaml.tmpl
  - path: xebialabs/xld-elastic-beanstalk-environments.yaml.tmpl
  - path: xebialabs/xlr-elastic-beanstalk-pipeline-ci-cd.yaml.tmpl
  - path: xebialabs/xlr-elastic-beanstalk-pipeline-destroy.yaml.tmpl
  # CloudFormation
  - path: cloudformation-elastic-beanstalk//beanstalk.yaml.tmpl
  - path: cloudformation-elastic-beanstalk//python-app-v1.zip
