Created
June 15, 2019 16:58
-
-
Save sanudatta11/f5d32f66a3d4ce0d583c2edc5bb51e1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AWSTemplateFormatVersion: 2010-09-09 | |
| Description: "This is the first CF Template for running Rundeck via UserData!" | |
| Parameters: | |
| NameOfService: | |
| Description: "The name of the service this stack is to be used for." | |
| Type: String | |
| KeyName: | |
| Description: Name of an existing EC2 KeyPair to enable SSH access into the server | |
| Type: AWS::EC2::KeyPair::KeyName | |
| Resources: | |
| EC2: | |
| Type: AWS::EC2::Instance | |
| Properties: | |
| AvailabilityZone: | |
| Fn::Select: | |
| - 0 | |
| - Fn::GetAZs: '' | |
| ImageId: ami-00e782930f1c3dbc7 | |
| InstanceType: t2.micro | |
| KeyName: !Ref KeyName | |
| UserData: | |
| "Fn::Base64": | |
| !Sub | | |
| #!/bin/bash | |
| yum -y install java-1.8.0 | |
| rpm -Uvh https://repo.rundeck.org/latest.rpm | |
| yum -y install rundeck | |
| service rundeckd start | |
| export DNS_NAME=$(curl -s http://169.254.169.254/latest/meta-data/public-hostname/) | |
| echo $DNS_NAME | |
| sed -i "s/localhost/$DNS_NAME/g" /etc/rundeck/rundeck-config.properties | |
| yum upgrade rundeck rundeck-config | |
| service rundeckd restart | |
| service rundeckd start | |
| echo NameOfService=${NameOfService} | |
| SecurityGroupIds: | |
| - !Ref RunDeckSG | |
| Tags: | |
| - Key: Name | |
| Value: !Ref NameOfService | |
| RunDeckSG: | |
| Type: AWS::EC2::SecurityGroup | |
| Properties: | |
| GroupDescription: Open Ports 22 and 4440 | |
| SecurityGroupIngress: | |
| - IpProtocol: tcp | |
| FromPort: 22 | |
| ToPort: 22 | |
| CidrIp: 0.0.0.0/0 | |
| - IpProtocol: tcp | |
| FromPort: 4440 | |
| ToPort: 4440 | |
| CidrIp: 0.0.0.0/0 | |
| Outputs: | |
| URL: | |
| Description: The Public DNS for the Rundeck EC2 Instance | |
| Value: !Sub 'http://${EC2.PublicDnsName}:4440' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment