Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Adding Cloudformation templates
Browse files Browse the repository at this point in the history
  • Loading branch information
fruch committed Sep 25, 2019
1 parent 15bb0a7 commit a0be16d
Show file tree
Hide file tree
Showing 8 changed files with 1,719 additions and 0 deletions.
66 changes: 66 additions & 0 deletions cloudformation/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!groovy
pipeline {
agent {
label {
label "aws-sct-builders-eu-west-1"
}
}
options {
timestamps()
disableConcurrentBuilds()
timeout([time: 30, unit: 'MINUTES'])
buildDiscarder(logRotator(numToKeepStr: '20'))
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('create virtualenv') {
steps {
script {
wrap([$class: 'BuildUser']) {
dir('cloudformation') {
sh """
#!/bin/bash
set -xe
python3 -m venv .venv3
source .venv3/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
"""
}
}
}
}
}
stage('test') {
steps {
script {
wrap([$class: 'BuildUser']) {
dir('cloudformation') {
sh """
#!/bin/bash
set -xe
source .venv3/bin/activate
# regenerate the teample
jinja2 scylla.yaml.j2 > scylla.yaml
# lint the template
cfn-lint --template scylla.yaml --region us-east-1
# running the test
pytest --log-cli-level info
"""
}
}
}
}
}
}
}
36 changes: 36 additions & 0 deletions cloudformation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Installation
```
python3 -m venv .venv3
source .venv3/bin/activate
install -r requirements.txt
```

## Testing
``` bash
# regenerate the teample
jinja2 scylla.yaml.j2 > scylla.yaml

# lint the template
cfn-lint --template scylla.yaml --region us-east-1

# running the test
pytest --log-cli-level info
```

# Using the template
```
# run the template from command line
aws cloudformation create-stack --region eu-west-1 --stack-name fruch-test-05 --template-body file://scylla.yaml \
--parameters ParameterKey=KeyName,ParameterValue=scylla-qa-ec2 \
ParameterKey=InstanceType,ParameterValue=i3.large \
ParameterKey=AvailabilityZone,ParameterValue=eu-west-1a \
ParameterKey=ClusterName,ParameterValue=fruch \
ParameterKey=InstanceCount,ParameterValue=3 \
ParameterKey=ScyllaAmi,ParameterValue=ami-0ececa5cacea302a8
```
Example of link to start the cloudforamtion:

https://eu-west-1.console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/create/review?templateURL=https://s3-eu-west-1.amazonaws.com/cf-templates-1jy8um4tbzwit-eu-west-1/2019241R3e-scylla.templateenk889k0zz&stackName=fruch-test&param_ScyllaAmi=ami-0ececa5cacea302a8


5 changes: 5 additions & 0 deletions cloudformation/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def pytest_addoption(parser):
parser.addoption("--keep-cfn", action="store_true", default=False)
parser.addoption("--stack-name", action="store", default=None)
parser.addoption("--region", action="store", default="us-east-1")
parser.addoption("--ami", action="store", default="ami-0b48ed57ebc0d5f06")
3 changes: 3 additions & 0 deletions cloudformation/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
log_format = %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
5 changes: 5 additions & 0 deletions cloudformation/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cfn-lint==0.23.4
boto3==1.9.216
pytest==5.1.1
Jinja2==2.10.1
jinja2-cli==0.7.0
Loading

0 comments on commit a0be16d

Please sign in to comment.