Unable to Upload Artifact Referenced by Aws Parameters in Gitlab.

Past Ram Dileepan, Sr. Solutions Architect at AWS
By Santiago Cardenas, Sr. Solutions Architect, Serverless at AWS

In order to deliver serverless applications, customers ofttimes turn to DevOps principles to efficiently build, deploy, operate, and iterate on features and changes.

Continuous integration and continuous deployment (CI/CD) is i of the major components of DevOps that helps deliver code faster and more reliably to production.

The continuous integration offering from GitLab, an AWS Partner Network (APN) Advanced Technology Partner with the AWS DevOps Competency, provides a rich set of features for automating how new code is incorporated into your software and how new versions of your software get congenital and deployed.

In this post, yous volition acquire how to create a sample serverless application using AWS Serverless Awarding Model (SAM) and how GitLab continuous integration helps with building, testing, and deploying the application in your Amazon Spider web Services (AWS) account.

Almost AWS Serverless Application Model

A serverless application is comprised of multiple resource, which can include functions, event sources, datastores, and other resource that piece of work together to perform tasks.

Serverless applications are more just AWS Lambda functions—they can include additional resources, such as APIs, databases, and effect source mappings.

AWS Serverless Application Model is an open source framework for building serverless applications. SAM includes the AWS SAM Template Specification and AWS SAM Control Line Interface (CLI).

The AWS SAM Template Specification is an extension of AWS CloudFormation used to define your serverless application resource as a template. Information technology provides a more than user-friendly and concise syntax to express functions, APIs, databases, and event source mapping when compared to typical CloudFormation template.

The CLI enables yous to build, test, and deploy serverless applications that are defined using a SAM template.

Getting Started

To become started, ensure you have your own GitLab business relationship and AWS account. This mail assumes you lot accept required permissions to configure Gitlab CI/CD pipelines and create AWS resources in your account.

We will create a sample serverless application using the SAM CLI and deploy it to an AWS business relationship using GitLab CI/CD pipeline. We'll employ GitLab as the repository for our source lawmaking.

When a programmer checks in their new code, the GitLab continuous integration fetches the source code from the repository, and so build, package, and deploy to the AWS business relationship.

These are the steps in this procedure:

  1. Install and configure the SAM CLI.
  2. Create an AWS serverless application using SAM CLI.
  3. Craft the .gitlab-ci.yml file.
  4. Prepare your AWS credentials in your GitLab account.
  5. Test locally.
  6. Deploy your application.
  7. Test your deployment.

Stride i: Install and Configure the SAM CLI

Some steps in this documentation utilise the SAM CLI. Please follow the instructions on installing SAM CLI.

If y'all use AWS Cloud9 equally your integrated evolution environment (IDE), the AWS Command Line Interface (CLI), SAM CLI, Docker, and necessary Docker images are installed for you.

Create an Amazon Unproblematic Storage Service (Amazon S3) bucket in your AWS business relationship to store the congenital package for deployment. Provide required permissions to the user you lot will be using in afterward steps to deploy the SAM awarding to write to this bucket.

Step ii: Creating an AWS SAM Application Using SAM CLI

You can create a serverless application past defining all required resources in an AWS SAM template. AWS SAM also provides some quick-kickoff templates to create an awarding. In this post, we'll use one of those templates to create a sample application.

Before you create a SAM application, create a new GitLab projection and clone it to your local environment. To create a SAM app from the CLI, open a final, change to the newly cloned projection, and enter the following text:

sam init -r python3.8 -n gitlab-example --app-template "how-do-you-do-world"

This creates a SAM app named gitlab-example using the default configuration, a single Python iii.viii part invoked by an Amazon API Gateway endpoint.

To meet additional runtimes supported by SAM and options for sam init, enter sam init -h.

Git push button the application back to the GitLab projection.

Pace 3: Crafting the .gitlab-ci.yml File

GitLab CI/CD pipelines are configured using a YAML file called .gitlab-ci.yml inside each project. This defines the structure and society of the pipelines.

In a.gitlab-ci.yml file in the root of your project, place the following code and replace the #S3Bucket# with the Amazon S3 bucket proper name you created to store the package:

Let's examine the config file more than closely:

  • The Docker image to utilise for this build is specified and pulled from the Docker hub. The image with Python 3.8 is used in this example since the sample awarding is written in Python 3.viii.
  • AWS Command Line Interface and AWS SAM CLI are installed in the script section.
  • SAM builds, packages, and deploys the application.

Every bit part of the CI/CD process, nosotros recommend you scan your code for quality and vulnerabilities in bundled libraries. Yous can detect these security offerings from our AWS Lambda Technology Partners.

Footstep four: Setting Up Your AWS Credentials with GitLab

To interact with your AWS account, the GitLab CI/CD pipelines require both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to be defined in your GitLab project settings. You can do this underSettings > CI/CD > Variables. For more data, please come across this GitLab ReadMe.

The AWS credentials you provide must include AWS Identity and Access Management (IAM) policies that provision right access control to AWS Lambda, Amazon API Gateway, AWS CloudFormation, and IAM resources.

Pace 5: Testing Locally

SAM provides functionality to test your applications locally. As we mentioned before, you must have SAM CLI installed locally for you to test locally.

SAM provides a default consequence inevents/issue.json that includes a message trunk of {\"message\": \"how-do-you-do world\"}. If you pass that upshot into the HelloWorldFunction, it should respond with the same body:

sam local invoke HelloWorldFunction -e events/event.json

Output should be:

{"message": "hello globe"}

After yous confirm the Lambda role is working every bit expected, y'all can test the API Gateway using the following steps.

First offset the API locally:

sam local start-api

SAM again launches a Docker container, this time with a mocked API Gateway listening on localhost:3000. Now, yous can phone call the howdy API equally follows:

ringlet http://127.0.0.1:3000/hello

Output again should be:

{"message": "hello world"}

Stride 6: Deploying Your Application

Git button the changes to your GitLab repository, and the GitLab pipeline will automatically deploy your awarding. If your build and deploy are successful, go to the next step to examination your deployed application.

If your build fails, delight take a look at the build log to see why it failed. Some common reasons are:

  • Incompatible versions of software (for case, the Python runtime version may exist different from the Python on the build machine). Address this by installing the proper versions of the software. If your build auto has an incompatible version of the software, install the proper version via the .gitlab-ci.yml file.
  • You may not be able to access your AWS business relationship from GitLab. Cheque the environment variables you configured with AWS credentials under the CI/CD settings in GitLab.
  • Y'all may not have permission to deploy a serverless application. Make sure you provide all required permissions to deploy a serverless awarding. Your credentials must accept permissions to the S3 saucepan, in improver to existence able to create the necessary resource of the sample SAM app.

Stride vii: Testing Your Application

To test the application you deployed, go to the build log and click on Show Consummate Raw in the upper right corner.

GitLab-CI-CD-1.1

Await for the HelloWorldApi – API Gateway endpoint similar to shown beneath.

GitLab-CI-CD-2.1

Finally, apply curl to test the API:

roll https://<api-id>.execute-api.us-east-1.amazonaws.com/Prod/hello/

Output should exist:

{"message": "hello earth"}

Conclusion

In this post, yous used GitLab continuous integration and AWS Serverless Application Model to create, build, examination, and deploy a serverless application. With GitLab, users tin build and deploy serverless applications with minimal configuration to accept advantage of continuous integration for serverless application development.

Learn more most GitLab and AWS Serverless Awarding Model (SAM).

.
GitLab-APN-Blog-CTA-1
.


GitLab – APN Partner Spotlight

GitLab is an AWS DevOps Competency Partner. Its continuous integration offering provides a rich fix of features for automating how new code is incorporated into your software and how new versions of your software get built and deployed.

Contact GitLab | Solution Overview | AWS Market

*Already worked with GitLab? Rate this Partner

*To review an APN Partner, you must be an AWS customer that has worked with them directly on a project.

millerpres1944.blogspot.com

Source: https://aws.amazon.com/blogs/apn/using-gitlab-ci-cd-pipeline-to-deploy-aws-sam-applications/

0 Response to "Unable to Upload Artifact Referenced by Aws Parameters in Gitlab."

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel