Integrate SonarQube with AWS CodeBuild - amazon-web-services

Is there a way to integrate SonarQube with AWS CodeBuild?
Since I cannot install any plugins on AWS CodeBuild, I would like some advice on how to achieve this.
------EDIT--------
I think I can use https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

I recently integrated SonarQube with Codebuild -
https://github.com/aws-samples/aws-codebuild-samples/blob/master/buildspecs/sonarqube.yml
This buildspec file gets you started. Dont forget to copy your sonar scanner properties to /sonar-scanner-3.0.3.778-linux/bin/

Related

using AWS Codepipeline to create and API gateway

Is it possible to create a new REST api gateway using codepipeline? I already have a terraform script to create the pipeline, but I want to know if there is a way to create a pipeline that will take my script and propogate it from a dev environment api gateway to a test environment? I am trying to automate the pipeline to possibly run the script for me once the code is updated in a code commit stash
Any suggestions would be greatly appreciated.
To run a script from AWS CodePipeline you can use AWS CodeBuild action in one of your CodePipeline stages.
With CodeBuild you can specify the list of commands you want to run, like installing and running terraform.

How to build with jenkins and deploy on aws?

I have the following task. I have a spring-boot app(backend), and a react app(frontend). I want to build the apps and deploy them on aws. I want to build them with Jenkins. What is the right way to do it? Should Jenkins be on a separate instance and deploy the apps on other instances? Should I use ECS? Using ECS with Jenkins seems like a complex task. The information online is confusing. If you have some guides that would be great.
if you want to deploy to AWS : the easiest way to get started is to use aws developer tools
code commit - to store your source code. it is based on git
code build - to build and test your code.
code depoy - to deploy on ec2 instances or ECS, whatever you like
Code pipeline - to connect 1, 2 and 3 and it also allows you to choose Jenkins in place of code build.
https://aws.amazon.com/products/developer-tools/

Using Powershell to perform the .Netcore Visual Studio AWS Toolkit 'Publish to AWS Lambda...'

I used Visual Studio 2017 with the AWS Toolkit to develop a .Net Core lambda function. I have Cloudformation script in a file called serverless.template and a deployment configuration in a file called aws-lambda-tools-defaults.json. While developing the project I've been deploying it to an AWS development account using the 'Publish to AWS Lambda...' right click option in the Solution Explorer.
I'm now ready to move to deploying this to our staging and production AWS accounts and need to perform the 'Publish to AWS Lambda...' deployment step using Cloudformation, with an ambition that we create Cloudformation Change Sets, to allow review prior to deployment.
I've been trying to work out what to do and have experimented with the 'aws cloudformation package' and 'sam package' CLI commands, but I can't seem to find a way forward.
Can anyone help me to understand the steps which 'Publish to AWS Lambda...' performs? I'd like to reproduce the steps in Powershell as this will provide me with the understanding I need to move on.
Thanks.
To deploy from the command line, use the dotnet CLI extension for Lambda. It's the same code that runs inside Visual Studio when you publish from the wizard, and can read the defaults file etc so you get a consistent deployment experience regardless of whether you deploy from the IDE or the command line.
You mention you want to understand what's going on behind the scenes - these tools are open source so you can take a look at all the work it does for you in this GitHub repository. When deploying a serverless application, CloudFormation change sets are used automatically, you don't need to handle it yourself.
The tool is a .NET Core global tool which you first install from the command line:
dotnet tool install -g Amazon.Lambda.Tools
Once installed, you can get help etc:
PS C:\> dotnet lambda help
Amazon Lambda Tools for .NET Core applications (3.2.0)
Project Home: https://github.com/aws/aws-extensions-for-dotnet-cli, https://github.com/aws/aws-lambda-dotnet
Commands to deploy and manage AWS Lambda functions:
deploy-function Command to deploy the project to AWS Lambda
invoke-function Command to invoke a function in Lambda with an optional input
list-functions Command to list all your Lambda functions
delete-function Command to delete a Lambda function
get-function-config Command to get the current runtime configuration for a Lambda function
update-function-config Command to update the runtime configuration for a Lambda function
Commands to deploy and manage AWS Serverless applications using AWS CloudFormation:
deploy-serverless Command to deploy an AWS Serverless application
list-serverless Command to list all your AWS Serverless applications
delete-serverless Command to delete an AWS Serverless application
Commands to publish and manage AWS Lambda Layers:
publish-layer Command to publish a Layer that can be associated with a Lambda function
list-layers Command to list Layers
list-layer-versions Command to list versions for a Layer
get-layer-version Command to get the details of a Layer version
delete-layer-version Command to delete a version of a Layer
Other Commands:
package Command to package a Lambda project into a zip file ready for deployment
package-ci Command to use as part of a continuous integration system.
To get help on individual commands execute:
dotnet lambda help <command>
To deploy your project from the command line, first cd into the project folder then execute the command
dotnet lambda deploy-serverless
This will read the settings in the defaults file and perform the deployment for you, just as if you'd used the IDE wizard.
Hope this, in conjunction with the open source repo, helps you dig into the steps involved.

AWS: execute script when deploying Application?

I would like to use EB CLI to deploy my PHP Application to AWS ElasticBeanstalk but I am wondering if there is a way to execute additional commands, for example download dependencies and compile files, etc.
Do I need to create a script? If yes how can I do it?
Any documentation is very appreciated.
Thank you
In general, the idea of beanstalk is that you do all the downloading of dependencies etc yourself (ideally in a CI pipeline), create a deployable package and then hand it over to beanstalk for deployment and execution.
You may want to look into AWS CodePipeline for running scripts, building and packaging before deploying to beanstalk.

Automate code deploy from Git lab to AWS EC2 instance

We're building an application for which we are using GitLab repository. Manual deployment of code to the test server which is Amazon AWS EC2 instance is tedious, I'm planning to automate deployment process, such that when we commit code, it should reflect in the test instance.
from my knowledge we can use AWS code-deploy service to fetch the code from GitHub. But code deploy service does not support GitLab repository . Is there a way to automate the code deployment process to AWS Ec2 instance through GitLab. or Is there a shell scripting possibility to achieve this? Kindly educate me.
One way you could achieve this with AWS CodeDeploy is by using the S3 option in conjunction with Gitlab-CI: http://docs.aws.amazon.com/codepipeline/latest/userguide/getting-started-w.html
Depending on how your project is setup, you may have the possibility to generate a distribution Zip (Gradle offers this through the application plugin). You may need to generate your "distribution" file manually if your project does not offer such a capability.
Gitlab does not offer a direct S3 integration, however through the gitlab-ci.yml you would be able to download it into the container and run the necessary upload commands to put the generated zip file on the S3 container as per the AWS instructions to trigger the deployment.
Here is an example of what your brefore-script could look like in the gitlab-ci.yml file:
before_script:
- apt-get update --quiet --yes
- apt-get --quiet install --yes python
- pip install -U pip
- pip install awscli
The AWS tutorial on how to use CodeDeploy with S3 is very detailed, so I will skip attempting to reproduce the contents here.
In regards to the actual deployment commands and actions that you are currently performing manually, AWS CodeDeploy provides the capability to run certain actions through scripts defined in the app-spec file depending on event hooks for the application:
http://docs.aws.amazon.com/codedeploy/latest/userguide/writing-app-spec.html
http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html
http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref-hooks.html
I hope this helps.
This is one of my old post. But I happened to find an answer for this. Although my question is specific to work with code deploy I would say there is no such need to use any aws requirements using gitlab.
We don't require Code Deploy at all. There is no need to use any external CI server like the team city or the jenkins to perform the CI from the GitLab anymore.
We need to add the .gitlab-ci.yml file in the source directory of the branch and write an .yml script in it. There are pipelines in the GitLab that will perform the CI/CD automatically.
The pipelines of the GitLab CI/CD looks more similar to the working functionality of Jenkins Server. using the YML script we can perform SSH on the EC2 instance and place the files in it.
An example of how to write the gitlab .yml file to ssh to ec2 instance is here https://docs.gitlab.com/ee/ci/yaml/README.html