Skip to content

Commit

Permalink
Merge pull request #127 from kcagran/backstage-templates
Browse files Browse the repository at this point in the history
Backstage templates
  • Loading branch information
GomathiselviS authored Dec 17, 2024
2 parents 1c2b0e9 + 3cc1222 commit de22d7f
Show file tree
Hide file tree
Showing 3 changed files with 283 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: cloud-configure-ec2
title: AWS Operations / Create EC2 Instance
description: This wizard will guide you on how to create EC2 instance in the Amazon cloud
namespace: default
tags:
- aap-operations
- intermediate
- cloud-aws-ops
- configure-ec2-pattern
- create-ec2-instance
spec:
type: service
parameters:
- title: Prompts
description: Create EC2 instance in the Amazon cloud
required:
- token
- inventory
properties:
token:
title: Token
type: string
description: Oauth2 token
ui:field: AAPTokenField
ui:widget: password
ui:backstage:
review:
show: false
inventory:
title: Inventory
description: Please enter the inventory you want to use the services on
resource: inventories
ui:field: AAPResourcePicker
credentials:
title: Credentials
description: Select credentials for accessing AWS.
The credentials need to be of type "Amazon Web Services".
type: array
ui:field: AAPResourcePicker
resource: credentials
verbosity:
title: Verbosity
description: Control the level of output Ansible will produce as the playbook executes.
resource: verbosity
ui:field: AAPResourcePicker
- title: Survey
required:
- aws_region
- instance_name
- instance_type
description: Create EC2 instance in the Amazon cloud
properties:
aws_region:
title: AWS Region
description: AWS region where resources should be created
type: string
ui:options:
rows: 5
instance_name:
title: Instance Name
description: Name of EC2 instance to create
type: string
ui:options:
rows: 5
instance_type:
title: Instance Type
description: Type of EC2 instance to create (e.g., t2.micro, m5.large)
type: string
ui:options:
rows: 5
ami_id:
title: AMI ID
description: Amazon Machine Image (AMI) ID to use for the instance, if not provided will default to the RHEL 9 AMI for the provided region and instance type
type: string
ui:options:
rows: 5
key_name:
title: Key Pair Name
description: Name of key pair to use for SSH access to the EC2 instance. If the key does not exist or is not provided, the instance will not be accessible via SSH.
type: string
ui:options:
rows: 5
wait_for_state:
title: Wait for State
description: Whether to wait for the EC2 instance to be in the running state before continuing. Defaults to true
type: string
enum:
- ""
- 'true'
- 'false'
instance_tags:
title: Instance Tags
description: 'A dict of tags for the instance, e.g. {"environment: test", "owner": "team foobar"}'
type: string
ui:options:
rows: 5
vpc_name:
title: VPC Name
description: Name of the VPC to create. Defaults to '{{instance_name}}-vpc'
type: string
ui:options:
rows: 5
vpc_cidr:
title: VPC CIDR Block
description: CIDR block to use for the VPC being created. Defaults to 10.0.0.0/24
type: string
ui:options:
rows: 5
subnet_cidr:
title: Subnet CIDR block
description: CIDR block to use for the subnet being created. 10.0.0.0/25
type: string
ui:options:
rows: 5
sg_name:
title: Security Group Name
description: Name of the security group to create for securing traffic to the instance. Defaults to '{{ instance_name }}-sg'
type: string
ui:options:
rows: 5
sg_description:
title: Security Group Description
description: Description for the security group. Defaults to 'Security group for EC2 instance {{ instance_name }}'
type: string
ui:options:
rows: 5
sg_rules:
title: Security Group Rules
description: 'A list of security group rules in yaml format, e.g.: - proto: tcp ports: 80 cidr_ip: 0.0.0.0/0 Defaults to allowing SSH access from within the VPC'
type: string
ui:options:
rows: 5
ui:widget: textarea
external_access:
title: Create External Access Resources
description: Whether to create resources for external access to the EC2 instance. Defaults to true. When true, adds security groups rules allowing inbound HTTP and HTTPS traffic, creates an internet gateway, creates a custom route table routing all internet traffic to the gateway, and allocates an elastic IP address for the instance.
type: string
enum:
- ""
- 'true'
- 'false'

steps:
- id: launch-job
name: Launch AWS Operations / Create EC2 Instance
action: rhaap:launch-job-template
input:
token: ${{ parameters.token }}
values:
inventory: ${{ parameters.inventory }}
credentials: ${{ parameters.credentials }}
verbosity: ${{parameters.verbosity}}
extraVariables:
aws_region: ${{ parameters.aws_region }}
instance_name: ${{ parameters.instance_name }}
instance_type: ${{ parameters.instance_type }}
ami_id: ${{ parameters.ami_id }}
key_name: ${{ parameters.key_name }}
wait_for_state: ${{ parameters.wait_for_state }}
instance_tags: ${{ parameters.instance_tags }}
vpc_name: ${{ parameters.vpc_name }}
vpc_cidr: ${{ parameters.vpc_cidr }}
subnet_cidr: ${{ parameters.subnet_cidr }}
sg_name: ${{ parameters.sg_name }}
sg_description: ${{ parameters.sg_description }}
sg_rules: ${{ parameters.sg_rules }}
external_access: ${{ parameters.external_access }}
output:
text:
- title: AWS Operations / Create EC2 Instance template executed
successfully
content: |
**Job ID:** ${{ steps['launch-job'].output.data.id }}
**Job STATUS:** ${{ steps['launch-job'].output.data.status }}
links:
- title: View in RH AAP
url: ${{ steps['launch-job'].output.data.url }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: cloud-terminate-ec2
title: AWS Operations / Terminate EC2 Instance
description: This wizard will guide you on how to terminate EC2 instance in the Amazon cloud
namespace: default
tags:
- aap-operations
- intermediate
- cloud-aws-ops
- configure-ec2-pattern
- terminate-ec2-instance
spec:
type: service
parameters:
- title: Prompts
description: Terminate EC2 instance in the Amazon cloud
required:
- token
- inventory
properties:
token:
title: Token
type: string
description: Oauth2 token
ui:field: AAPTokenField
ui:widget: password
ui:backstage:
review:
show: false
inventory:
title: Inventory
description: Please enter the inventory you want to use the services on
resource: inventories
ui:field: AAPResourcePicker
credentials:
title: Credentials
description: Select credentials for accessing AWS.
The credentials need to be of type "Amazon Web Services".
type: array
ui:field: AAPResourcePicker
resource: credentials
verbosity:
title: Verbosity
description: Control the level of output Ansible will produce as the playbook executes.
resource: verbosity
ui:field: AAPResourcePicker
- title: Survey
required:
- aws_region
- instance_name
description: Terminate EC2 instance in the Amazon cloud
properties:
aws_region:
title: AWS Region
description: AWS region where resources should be deleted
type: string
ui:options:
rows: 5
instance_name:
title: Instance Name
description: Name of EC2 instance to delete
type: string
ui:options:
rows: 5
key_name:
title: Key Pair Name
description: Name of key pair to delete for SSH access to the EC2 instance. Defaults to '{{ instance_name }}-key'
type: string
ui:options:
rows: 5
vpc_name:
title: VPC Name
description: Name of the VPC to delete. Defaults to '{{instance_name}}-vpc'
type: string
ui:options:
rows: 5
steps:
- id: launch-job
name: Launch AWS Operations / Terminate EC2 Instance
action: rhaap:launch-job-template
input:
token: ${{ parameters.token }}
values:
inventory: ${{ parameters.inventory }}
credentials: ${{ parameters.credentials }}
verbosity: ${{parameters.verbosity}}
extraVariables:
aws_region: ${{ parameters.aws_region }}
instance_name: ${{ parameters.instance_name }}
key_name: ${{ parameters.key_name }}
vpc_name: ${{ parameters.vpc_name }}
output:
text:
- title: AWS Operations / Terminate EC2 Instance template executed
successfully
content: |
**Job ID:** ${{ steps['launch-job'].output.data.id }}
**Job STATUS:** ${{ steps['launch-job'].output.data.status }}
links:
- title: View in RH AAP
url: ${{ steps['launch-job'].output.data.url }}

0 comments on commit de22d7f

Please sign in to comment.