Deploying an AWS CodeStar project on a different account - amazon-web-services

AWS CodeStar lets you spin up CodePipelines and CodeCommit repos to support your project. If I want to build a project in CodeStar and then take the resultant package, how can I deploy that package into another account?
For example, the basic "Python Web Service Lambda" CodeStar template generated these files,
$ ls ./ -R
./:
buildspec.yml index.py README.md template.yml tests
./tests:
test_handler.py
This notably lacks the templates for setting up the CodePipeline that deploys the code. Thus I am left to figure out how to deploy it myself.
How can I deploy the CodeStar templates onto a different AWS account?

You can not. Currently (2019-01-10) The CodeStar functionality is limited. CodeStar Projects can only be created via the web console and can not be imported / exported / codified. Sadly CodeStar is only a web console feature at this time.

Related

AWS CodeCommit does support Git LFS?

I have existing project repo in gitlab. Since the gitlab is running in the server, we have the lfs objects in certain directory. My Doubt is AWS Codecommit does not have seperate server to store any lfs configurations as gitlab or bitbucket. I've to configure the lfs directory in AWS CodeCommit. My Question is "Does AWS CodeCommit supports Git LFS?". If yes,can someone explain how to configure AWS CodeCommit with Git LFS?

AWS reference solution for a serverless SaaS system - Error: Template file not found - template.yml

I'm trying to deploy an AWS reference solution using AWS Cloud9, that demonstrates a sample SaaS system. The repo for the solution is here:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/blob/main/DOCUMENTATION.md
There's a deployment file that can be run in order to bootstrap the example system in AWS - it's /aws-saas-factory-ref-solution-serverless-saas/deployment.sh within the repo.
Part of the deployment script builds bootstrap resources using the file /aws-saas-factory-ref-solution-serverless-saas/server/bootstrap-template.yaml, which is a CloudFormation template. The script then deploys bootstrap resources based on the configuration file /aws-saas-factory-ref-solution-serverless-saas/server/samconfig-bootstrap.toml
The relevant parts of ./deployment.sh that perform the build and bootstrap are as follows. The build and deployment utilise the AWS 'Serverless Application Model' (sam):
sam build -t bootstrap-template.yaml --use-container --region=$REGION
sam deploy --config-file samconfig-bootstrap.toml --region=$REGION --parameter-overrides AdminEmailParameter=$1
When I run the ./deployment.sh on a Cloud 9 instance on EC2 (in Singapore region), I get the following error during the common resource bootstrapping stage:
[11034] Failed to execute script main
sam deploy --config-file samconfig-bootstrap.toml --region=ap-southeast-1 --parameter-overrides AdminEmailParameter=chris.halcrow#elenium.com
Error: Template file not found at /home/ec2-user/environment/aws-saas-factory-ref-solution-serverless-saas/server/template.yml
I'm not seeing anything when I search the code for template.yml, so I'm not sure what's attempting to reference this. The file isn't present in the solution.
The guide here describes how to quickly set up an AWS Cloud9 environment running on an EC2 instance, into which the solution can be cloned from its Github repo in order to run the ./deployment.sh script - https://catalog.us-east-1.prod.workshops.aws/workshops/b0c6ad36-0a4b-45d8-856b-8a64f0ac76bb/en-US/pre-requisites/12-own-aws-account
After looking at the build-spec file (buildspec.yaml files are used to provide meta-data for CI/CD in AWS CodeBuild), it seems that the AWS team is testing the deployment using CI/CD Pipelines and forgot to update the shell script.
You on the other hand don't need to worry about the the build-spec file.
Solution
Go and just change template.yml to tenant-template.yaml
I found out that template.yml is an artifact that's normally produced during the build process - see SAM deploy command reference
sam deploy
By default when you use this command, the AWS SAM CLI assumes that
your current working directory is your project's root directory. The
AWS SAM CLI first tries to locate a template file built using the sam
build command, located in the .aws-sam subfolder, and named
template.yaml.
It seems that the template.yml wasn't being created due to insufficient memory size of the EC2 instance that Cloud9 was running in.
The solution for this was provided by #ujwalbukka in the following git issue, within the repo for the reference solution:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/issues/19
To get the SaaS reference solution to run in Cloud9, I cloned an additional repo inside Cloud9 (the repo for the AWS workshop for the SaaS reference solution). I cloned this using git clone https://github.com/aws-samples/aws-serverless-saas-workshop.git
After cloning that repo, I ran through the steps here to run scripts that exist in the workshop repo, that increase the Cloud9 EC2 instance size and install the prerequisites for running the reference solution.

Deploy to AWS EC2 from AWS S3 via Bitbucket Pipelines

I have a requirement to do CI/CD using Bitbucket Pipelines.
We use Maven to build our code on Bitbucket pipelines and push the artifacts (jars) to AWS S3. The missing link is to figure out a way to get the artifacts from S3 and deploy to our EC2 instance.
It should all work from Bitbucket Pipelines yml - hopefully using Maven plugins.
For pushing the artifacts to S3 we use:
<groupId>com.gkatzioura.maven.cloud</groupId>
<artifactId>s3-storage-wagon</artifactId>
Is there a way/plugin that will download the artifact from S3's bucket and deploy it to EC2 instance specific folder and perhaps call a sh script to run the jars?
Thank you!
Use AWS Code Deploy (https://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html) to deploy it to the EC2 instance. The trigger for code deploy would be the S3 bucket that you deploy your jars to. You will need to turn S3 versioning on to make it work. Code Deploy has it's own set of hooks that you can use to perform any shell command or run any bat files on the EC2.

In AWS Codestar, how to configure branch deployments to specific environments?

I just created a brand new AWS Codestar project.
As far as I can tell, that Codestar is just a dashboard that integrates multiple AWS products.
There is one thing that I don't know how to configure yet, and it is branch deployments.
In my git repository, I have 3 branches: master, develop and staging
In an ideal world, master deploys to production, develop to the development environment and staging to the QA environment.
I don't know how to configure this pipeline using AWS, and I haven't been able to locate to relevant documentation in their developers portal.
This is my buildspec.yml file just in case it can be configured there:
version: 0.2
phases:
install:
commands:
- echo Installing NPM Packages...
- npm install
build:
commands:
- aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template template-export.yml
artifacts:
type: zip
files:
- template-export.yml
This is a project that uses AWS API Gateway to route requests to AWS Lambda functions if that matters.
Sadly AWS CodePipline doesn't support passing in the git branch. Last year they have only added support to pass the git commit sha1 (more can be found here).
I'd suggest you follow the CodePipline docs here, to create 3 pipelines one for each branch (you can even create a special buildspec_dev.yaml or buildspec_prod.yaml, check out more examples here).

Is there a way to deploy to Elastic Beanstalk if you are not using git?

I am developing an Elastic Beanstalk app. It is a Scala web application, built with sbt. I want to deploy the resulting WAR from the command line to an existing environment.
All I can find is the eb CLI which appears to require you to use git: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-getting-started.html
Is there not a way to simply specify a WAR and environment name to perform the deployment?
What is the best workaround otherwise? I can upload to S3 from the command line and then use the web app to choose that file, but it's a bit more painful than I wanted.
You can use Elastic Beanstalk CLI (eb) instead of AWS CLI. Just run eb create to create a new environment and eb deploy to update your environment.
You can set specific artifact (your *.war file), by configuring the EB CLI (read: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-configuration.html#eb-cli3-artifact):
You can tell the EB CLI to deploy a ZIP or WAR file that you generate
as part of a separate build process by adding the following lines to
.elasticbeanstalk/config.yml in your project folder.
deploy:
artifact: path/to/buildartifact.zip
I found a way - use the aws CLI instead. First upload to S3 (I actually use s3cmd) then create an application version:
$ aws elasticbeanstalk create-application-version --application-name untaggeddb --version-label myLabel --source-bundle S3Bucket="bucketName",S3Key="key.war"
I believe the application version can then be deployed with update-environment also using the aws CLI.