How to deploy s3 bucket within a docker container in CDK? - amazon-s3

I am deploying a static site with AWS CDK. This works but as the site has grown, the deployments are failing due to
No space left on device
I am looking for solutions to this problem. One suggestion I have seen is to deploy within a docker container.
How can I do this in CDK and are there any other solutions?

I would advise that you use cdk-pipelines to manage your deployment - thats the best way forward.
But if you have to use a docker container then I have done something similar (in Jenkins).
Steps...
Create a 'Dockerfile' in your project, this will be your custom build environment, it should look like this...
FROM node:14.17.3-slim
ENV CDK_DEFAULT_ACCOUNT=1234 \
CDK_DEFAULT_REGION=ap-southeast-2
RUN npm install -g typescript
Make sure your pipeline installs any npm packages you need
'Build' your project, npx cdk synth
'Deploy' your project,npx cdk deploy --require-approval never
Lastly you'll need a way to authenticate with AWS so BB Pipelines and specifically the Docker container can 'talk' to cloudformation.
But like I said, cdk-pipelines is best solution, here is good tutorial

Related

How to change the local folder for an App Engine project?

TIA for your help.
I recently started experimenting with Google App Engine, and I have been able to set up a project successfully.
However, I made a mistake with the location of my local files and I would like to change it.
This is the output from my console when I deploy:
jnkrois#dev:~/Development/My_Project$ gcloud app deploy
Initializing App Engine resources...done.
You are about to deploy the following services:
My_Project/default/1234567890 (from [/home/jnkrois/Development/My_Project/app.yaml])
Notice that the local folder is /home/jnkrois/Development/My_Project/app.yaml
I want to change the gcloud settings in order to pull the files from my /var/www/html/My_Project/
That way I can run the project locally via my Apache server.
Thanks for your help.
That way I can run the project locally via my Apache server.
In the vast majority of cases you won't be able to run your GAE project through apache. Except, maybe, for a totally static website with a very particular config.
The proper way to run your GAE project locally is using the development server, see Using the Local Development Server
But to answer your question - there is no extra dependency of the project outside the project directory, so just move the project directory to where you want (up to you to check address any permission issues, assuming all permissions are met in the example below) and run the gcloud cmd from the new project location:
mv /home/jnkrois/Development/My_Project /var/www/html
cd /var/www/html/My_Project/
gcloud app deploy
Again, donno if this will help you run it through apache or not.

Travis config for deploying a static site without any build actions

I'd like to use Travis to push a static HTML/JavaScript website to an Amazon S3 bucket on each commit to master. Is there any way to configure my .travis.yml so it doesn't try to run any sort of build process? Just a deploy?
It seems like this is mainly controlled by the language setting which defaults to Ruby, so Ruby is being (unnecessarily) installed on each build.
I don't know how the ruby box works (I use the java box for my work); that being said, I think that the travis CI boxes have their base language already installed so you aren't really unnecessarily installing ruby each time.
If you want, there supposedly is an undocumented option language: generic.
This way you can just run the required bash commands to deploy your code to Amazon S3

Steps to get angular 2 universal starter to deploy to an external server host (Google Cloud, Azure, etc)?

I cloned universal-starter (webpack version) and have it up and running on my local machine using npm start and npm run watch per the instructions
Now stuck after npm run build and attempting to deploy to Azure (and Google Cloud) via the github integration - can't figure out how to set up either to work.
Anyone have a recipe on how to get the webpack bundled files to fire up on an external host with express.js? Do I need to run commands via a CI integration? The files in /dist don't seem to stand on their own.
At Netlify you can connect your git repo and tell them what build commands you want them to use. If you specify the "dist" directory, then they will deploy anything that gets in there (after they have compiled your application).
Edit: the lowest tier is free.
Edit2: I am not associated with Netlify. I just used them in my latest deploy, and found the process extremely easy.
Note: This has changed dramatically since Angular 2. While I'm now moved on to SSR, docker, and all kinds of other things, the simplest answer was to
1) Production build
ng build --prod
2) Transfer files to a static web host (i.e., I used awscli to connect to a s3 bucket when it was just a static site...I know use SSR so I need to use a node server like express)
3) Serve files (there are some complexities for redirect requirements for index.html for error and for 404...and of course setting the status for both redirects to 200)
4) Put something on the frontend for performance/ ssl/ etc. nginx or a CDN would make sense.

How do I start an Amazon EC2 VM from a saved AMI using Jenkins?

I'm trying to create a Jenkins job to spin up a VM on Amazon EC2 based on an AMI that I currently have saved. I've done my searching and can't find an easy way to do this other than through Amazon's GUI. This isn't very ideal as there are a lot of manual steps involved and it's time-consuming.
If anyone's had any luck doing this or could point me in the right direction that would be great.
Cheers,
Darwin
Unless I'm misunderstanding the question this should be possible using the cli, assuming you can install and configure the cli on your jenkins server you can just run the command as a shell script as part of the build.
Create an instance with CLI.
The command would be something along the lines of:
[path to cli]/aws ec2 run-instances --image-id ami-xyz
If your setup is too complicated for a single cli command, I would recommend creating a simple cloudformation template.
If you are unable to install the cli, you could use any number of sdk's e.g. java to make a simple application you could run with jenkins.
There is the Jenkins EC2 Plugin
Looking at the document it looks like you may be able to reuse your AMI. If not, you can configure it with an init script
Next, configure AMIs that you want to launch. For this, you need to
find the AMI IDs for the OS of your choice. ElasticFox is a good tool
for doing that, but there are a number of other ways to do it. Jenkins
can work with any Unix AMIs. If using an Ubuntu EC2 or UEC AMI you
need to fill out the rootCommandPrefix and remoteAdmin fields under
'advanced'. Windows is currently unsupported.

how to start sidekiq on engineyard

i am shifting a rails3 app from heroku to engine yard. I want to know how to start(or restart) sidekiq on engine yard on each deployment? To check that sidekiq is working, i ssh to EY instance and manually start sidekiq. I want this process to be handled from EY deployment script(config/deploy.yml). I am used to mina deployment and EC2.
Engine Yard provides two ways to customize your environment. You can use custom chef recipes, and deploy hooks.
For SideKiq you will want to use both. You will use a custom chef recipe to configure and run SideKiq, and a deploy hook to restart SideKiq each time you deploy new code.
Engine Yard provides a pre-made example custom chef recipe for SideKiq at http://github.com/engineyard/ey-cloud-recipes/tree/master/cookbooks/sidekiq. The documentation on the example recipe shows exactly what to use for your deploy hook as well.
To use the custom recipe, you will first need to install the engine yard gem locally (gem install engineyard). Then you will make a copy of their example repositories using git clone git#github.com:engineyard/ey-cloud-recipes.git.
Once you've cloned the repository, you will need to add require_recipe 'sidekiq' to ./ey-cloud-recipes/cookbooks/main/recipes/default.rb, then modify the sidekiq recipe as described in the documentation.
Once everything is complete, you can run ey recipes upload, and then ey recipes apply to apply the recipes to your environment. You may need to specify some command line options, depending on if the EY gem can guess which application and environment you are attempting to apply the recipes to. The output from the ey command should provide you with the information you need to do so.
After you've applied the recipes, you will want to create they deploy hooks inside your git repository that your application resides in. Create a 'deploy' directory in the root of your repository and add the after_restart.rb deploy hook as described on the sidekiq chef recipe's documentation.
Re-deploy and you should be good to go.
If you run into any problems, please put in a ticket at Engine Yard's support and we will be happy to assist you.