apiVersion: xl/v2
kind: Blueprint

metadata:
  name: AWS-Lambda-Basic
  description: |
    Creates a basic Lambda function and execution role
  author: XebiaLabs
  version: 2.0
  instructions: Please read the generated file "xebialabs/USAGE-basic-lambda.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:"
    options:
    - !expr "awsRegions('lambda')"

  - 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)"

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

  files:
  # XebiaLabs
  - path: xebialabs.yaml
  - path: README.md
  - path: xebialabs/USAGE-basic-lambda.md.tmpl
  - path: xebialabs/xld-basic-lambda-applications.yaml.tmpl
  - path: xebialabs/xld-basic-lambda-infrastructure.yaml.tmpl
  - path: xebialabs/xld-basic-lambda-environments.yaml.tmpl
  # CloudFormation
  - path: cloudformation-basic-lambda/lambda-function.yaml
