These AWS CloudFormation templates create a full application stack for a multitenant-ready Hyku application, including:
$ AWS_DEFAULT_REGION=us-east-1
Create or import an EC2 key-pair for that region.
Create a public hosted zone in Route53; the web application will automatically manage DNS entries in this zone. A registered domain name is needed to pair with the Route53 hosted zone. You can use Route53 to register a new domain or use Route53 to manage an existing domain.
Create an S3 bucket to be used for the persistent storage of binary content.
Create an IAM user and give that user permission to access the S3 bucket created in the previous step. In this case, setting user permissions by attaching an inline policy is recommended. Make sure to capture the new user's API access credentials.
(Optional) If creating the stack in a region other than us-east-1, create an additional S3 bucket the desired region with public read only permissions. This will be used to hold source bundles for Elastic Beanstalk environments. In total, the bucket needs files for solr, zookeeper, fedora, and hyku. To create the needed files:
Solr:
cd assets/solr
zip -r solr.zip .
Zookeeper:
cd assets/zookeeper
zip -r zookeeper.zip .
Hyku:
wget -O hyku.zip https://github.com/samvera-labs/hyku/archive/master.zip
Fedora:
wget https://hybox-deployment-artifacts.s3.amazonaws.com/fcrepo-webapp-ext-4.8.0-SNAPSHOT.war
Upload the archive files to your regional S3 bucket. The bucket and the file names will be referenced in a params file described below.
Copy the params/defaults.json
template to a new environment-specific file, populating the parameter values as appropriate for your environment. This repo ignores local files placed in the params/private/
directory and is where secret params can be set. Make sure to set values for at least these parameters (the default settings, while insecure, will work for the other parameters, and should suffice for development purposes):
KeyName
: the name of the key-pair created in step 1PublicZoneName
: the name of the hosted zone created in step 2 (with a trailing period)DatabasePassword
and FcrepoDatabasePassword
: password for Hyku and Fedora databasesFcrepoS3BucketName
: the name of the S3 bucket created in step 3FcrepoS3AccessKey
and FcrepoS3SecretKey
: API credentials for user created in step 4SecretKeyBase
: rails key generation baseS3BucketEB
: name of the S3 bucket that contains the Beanstalk source bundles described in step 5WebappS3Key
: name of the hyku zip file created in step 5SolrS3Key
: name of the solr zip file created in step 5ZookeeperS3Key
: name of the zookeeper zip file created in step 5S3FedoraFilename
: name of the fcrepo zip file created in step 5Create the full application stack:
$ aws --region $AWS_DEFAULT_REGION cloudformation create-stack --disable-rollback --stack-name hybox --template-body https://s3.amazonaws.com/hybox-deployment-artifacts/cloudformation/current/templates/stack.yaml --capabilities CAPABILITY_IAM --parameters file://params/private.json
The --disable-rollback parameter in this call prevents the entire stack from being torn down if an error occurs during the build process. Without this option, if the stack fails to create, a rollback will be performed to tear down the entire stack, making it more difficult to discern the cause of the failure.
You can also create (or update) your application from branches of the cloudformation repository:
$ aws --region $AWS_DEFAULT_REGION cloudformation create-stack --stack-name hybox --template-body https://s3.amazonaws.com/hybox-deployment-artifacts/cloudformation/branch/branch-name/templates/stack.yaml --capabilities CAPABILITY_IAM --parameters file://params/private.json
You can also deploy branches of the hybox application repository by setting the WebappS3Key
parameter for your stack to point at the branch-specific deployment artifact (e.g. hyku/branch/branch-name/hyku.zip
)
The stack will spin up in the following order:
|- stack
|- mail
|- slack
|- vpc
|- securitygroups
|- bastion
|- zookeeper
|- solr
|- redis
|- postgres
|- postgres-fedora
|- fcrepo
|- application
|- workers
|- webapp
|- codepipeline
(Optional) If you set the ContactEmail
parameter, which enables messages from the contact form to be sent to a specified email address, you will also need to verify that email address in SES. Go to the SES console (make sure to select the correct region) select Email Addresses then the Verify a new email address button. You will need to click a link from an email that is sent to complete the verification process.
(Optional) Enable HTTPS support
SETTINGS__SSL_CONFIGURED
with a value of true
SSLCertificateId
parameter to the certificate ARNupdate-stack
with CloudFormation (this can be done using the same command noted above for create-stack
, but without the --disable-rollback option.)The AWS CloudFormation stack must be deployed into an S3 bucket for CloudFormation to correctly resolve sub-stack references. The templates/travis.json
stack will bootstrap the necessary buckets, IAM user, and access keys to support continuous deployment from both this CloudFormation repository and the Hydra-in-a-Box application repository.
This bootstrapping is already provided for the main repositories, but if you deploy a fork of this stack, you may need to create this stack and configure continuous deployment for your forks. These files will expire from S3 after a period of time, so pushing a change to the repository may be required to republish the templates.
$ aws --region $AWS_DEFAULT_REGION cloudformation create-stack --stack-name travis --template-body file://templates/travis.json --capabilities CAPABILITY_IAM
You will need the outputs from this stack to create deploy steps for these repositories.
Based on AWS bills for accounts running this stack throughout 2017, the cost of running Hyku using the configuration defined in these templates is roughly $800-$900 per month. Variation will depend on configured instance minimums and usage/load.