This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 15k traffic Daily!!!

Streamline AWS Development with CI/CD, SAM, and GitHub Actions




Introduction:

When a good suggestion involves thoughts, how can or not it’s delivered to customers as shortly as attainable? for me, the answer is to implement CICD together with the mixture of Testing and Infrastructure as Code.

Steady Integration and Steady Deployment (CI/CD) has grow to be important observe in fashionable software program growth. πŸš€

It allows groups to automate and streamline the method of constructing, testing, and deploying purposes, decreasing handbook effort and guaranteeing quicker and extra dependable releases. Within the AWS ecosystem, CI/CD might be seamlessly built-in with AWS Serverless Utility Mannequin (SAM) and GitHub Actions.

Pipeline

This text explores the facility of CI/CD in AWS utilizing SAM and GitHub Actions, together with an instance of a ready-to-use Infrastructure as Code (IaC) template and integration testing as a part of the pipeline.

GitHub Repository



Understanding CI/CD and its Advantages: πŸš₯

Steady Integration is a observe the place engineers combine their work continuously, normally day by day, the thought is that every integration is validated by a set of exams and automatic builds.

Steady Supply is a observe the place we construct software program in a manner that it may be launched to manufacturing at any time, normally day by day and normally as one of many newest steps of a deployment pipeline.

Deploy software program with out handbook intervention. Chances are you’ll implement handbook approvals to deploy to manufacturing, however that is extra of a enterprise resolution than a technical one.

We have to make frequent, automated releases of our software program to scale back the suggestions cycles and be taught as a lot as attainable from our customers or clients.

The result’s empowered groups and fewer stress within the strategy of releasing software program.

Performed Means Launched

Lastly, the thought is to enhance constantly, be taught and adapt.



AWS Serverless Utility Mannequin (SAM): 🐿️

SAM is an open-source framework developed by AWS that simplifies the deployment and administration of serverless purposes. SAM extends AWS CloudFormation to supply a simplified syntax particularly designed for serverless assets.

  CommunityBuilderFunction:
    Sort: AWS::Serverless::Operate
    Properties:
      CodeUri: first_article/
      Handler: app.lambda_handler
      FunctionName: get-first-article
      Occasions:
        ArticleEvent:
          Sort: Api
          Properties:
            Path: /v1/articles
            Methodology: publish
            RestApiId: !Ref ApiDeployment
Enter fullscreen mode

Exit fullscreen mode

Advantages:

  • Simplified Serverless Utility Improvement
  • Native Improvement and Testing
  • Deployment and Infrastructure as Code
  • Constructed-in Greatest Practices
  • Simplified CI/CD



GitHub Actions: πŸ™

GitHub Actions Is a CI/CD platform supplied by GitHub that lets you automate varied workflows, duties, and processes immediately inside your GitHub repository.

Secrets and techniques are necessary within the context of CI/CD servers as a result of they help you save necessary data securely with out exposing delicate data.



Constructing a CI/CD Pipeline with SAM and GitHub Actions: πŸ™πŸΏοΈ

We are able to outline phases within the pipeline: construct, unit check, integration check, and deployment.

identify: Pipeline

on:
  push:
    branches:
      - 'principal'
...
  deploy-prod:
    if: github.ref == 'refs/heads/principal'
    wants: [integration-test]
    runs-on: ubuntu-latest
    steps:
      - makes use of: actions/checkout@v3
      - makes use of: aws-actions/setup-sam@v2
        with:
          use-installer: true
      - makes use of: actions/download-artifact@v3
        with:
          identify: packaged-prod.yaml

      - identify: Assume the prod pipeline consumer function
        makes use of: aws-actions/configure-aws-credentials@v1-node16
        with:
          aws-access-key-id: ${{ env.PIPELINE_USER_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ env.PIPELINE_USER_SECRET_ACCESS_KEY }}
          aws-region: ${{ env.PROD_REGION }}
          role-to-assume: ${{ env.PROD_PIPELINE_EXECUTION_ROLE }}
          role-session-name: prod-deployment
          role-duration-seconds: 3600
          role-skip-session-tagging: true

      - identify: Deploy to manufacturing account
        run: |
          sam deploy --stack-name ${PROD_STACK_NAME} 
            --template packaged-prod.yaml 
            --capabilities CAPABILITY_IAM 
            --region ${PROD_REGION} 
            --s3-bucket ${PROD_ARTIFACTS_BUCKET} 
            --no-fail-on-empty-changeset 
            --role-arn ${PROD_CLOUDFORMATION_EXECUTION_ROLE}
Enter fullscreen mode

Exit fullscreen mode



Infrastructure as Code (IaC) Template: πŸ“–

Infrastructure as Code (IaC) is necessary as a result of it allows constant, reproducible, and automatic provisioning and administration of infrastructure, leading to decreased handbook errors in software program growth and deployment processes.

Assets:
  HelloWorldFunction:
    Sort: AWS::Serverless::Operate # Extra information about Operate Useful resource: https://github.com/awslabs/serverless-application-model/blob/grasp/variations/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: hello_world/
      Handler: app.lambda_handler
      Runtime: python3.9
      Architectures:
        - x86_64
      Occasions:
        HelloWorld:
          Sort: Api # Extra information about API Occasion Supply: https://github.com/awslabs/serverless-application-model/blob/grasp/variations/2016-10-31.md#api
          Properties:
            Path: /hiya
            Methodology: get
Enter fullscreen mode

Exit fullscreen mode



Unit Testing and Integration Testing: 🦺

To make sure that we catch bugs and ship dependable software program, you will need to embody automated exams within the construct course of. Check-driven growth (TDD) is a useful gizmo in enhancing the design of the software program and giving us the boldness to deploy it to manufacturing. The extra complete and well-written our exams are, the extra assured we will probably be when deploying to manufacturing.



Greatest Practices and Issues: πŸ™ŒπŸ»

  • Implementing safety and compliance in CI/CD pipelines.
  • Managing environment-specific configurations.
  • Monitoring and logging for CI/CD pipelines.
  • Dealing with rollbacks and canary deployments.



Conclusion: πŸ€”

On this article, now we have explored the highly effective mixture of CI/CD, AWS SAM, and GitHub Actions.

Lastly, by leveraging CI/CD finest practices, infrastructure as code, and automatic testing, we are able to obtain quicker, extra dependable deployments whereas sustaining high-quality code.

I’ve at all times been a giant fan of infrastructure as code, and I feel Terraform, Pulumi, and CDK are additionally nice choices. Nonetheless, if our thought is to ship high-quality software program, empower builders, and simply check a speculation in manufacturing, I might go along with SAM. It is a highly effective instrument for growing serverless purposes.



Wrapping up

I might love to attach with you additionally on any of the next:

For those who loved the posts please comply with go to my weblog jorgetovar.dev

The Article was Inspired from tech community site.
Contact us if this is inspired from your article and we will give you credit for it for serving the community.

This Banner is For Sale !!
Get your ad here for a week in 20$ only and get upto 10k Tech related traffic daily !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to Contribute to us or want to have 15k+ Audience read your Article ? Or Just want to make a strong Backlink?