{"id":1580,"date":"2024-11-13T12:29:22","date_gmt":"2024-11-13T12:29:22","guid":{"rendered":"https:\/\/learnsysadmin.com\/?page_id=1580"},"modified":"2024-11-13T12:29:23","modified_gmt":"2024-11-13T12:29:23","slug":"ci-cd-pipeline-for-cloudfront-on-git-update","status":"publish","type":"page","link":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/","title":{"rendered":"CI\/CD Pipeline for CloudFront on GIT Update"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Creating a CI\/CD pipeline using AWS CodePipeline to push content to <strong>Amazon CloudFront<\/strong> when a Git repository is updated involves several steps. Below is a detailed process using <strong>Terraform<\/strong> to automate the infrastructure setup for this pipeline. The pipeline will:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Detect changes in a Git repository (e.g., GitHub).<\/li>\n\n\n\n<li>Build the content (if necessary).<\/li>\n\n\n\n<li>Deploy the content to an <strong>S3 bucket<\/strong>.<\/li>\n\n\n\n<li>Invalidate the <strong>CloudFront distribution<\/strong> to reflect the new changes.<\/li>\n<\/ol>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_71 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Summary of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#Overview_of_the_Steps\" title=\"Overview of the Steps:\">Overview of the Steps:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#Step_1_Create_the_Terraform_Project_Directory\" title=\"Step 1: Create the Terraform Project Directory\">Step 1: Create the Terraform Project Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#Step_2_Set_Up_Terraform_Configuration_Files\" title=\"Step 2: Set Up Terraform Configuration Files\">Step 2: Set Up Terraform Configuration Files<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#1_Provider_Configuration_providertf\" title=\"1. Provider Configuration (provider.tf)\">1. Provider Configuration (provider.tf)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#2_S3_Bucket_s3tf\" title=\"2. S3 Bucket (s3.tf)\">2. S3 Bucket (s3.tf)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#3_CloudFront_Distribution_cloudfronttf\" title=\"3. CloudFront Distribution (cloudfront.tf)\">3. CloudFront Distribution (cloudfront.tf)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#4_GitHub_Webhook_for_CodePipeline_github_webhooktf\" title=\"4. GitHub Webhook for CodePipeline (github_webhook.tf)\">4. GitHub Webhook for CodePipeline (github_webhook.tf)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#5_IAM_Role_and_Policies_iamtf\" title=\"5. IAM Role and Policies (iam.tf)\">5. IAM Role and Policies (iam.tf)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#6_Lambda_Function_for_CloudFront_Invalidation_lambdatf\" title=\"6. Lambda Function for CloudFront Invalidation (lambda.tf)\">6. Lambda Function for CloudFront Invalidation (lambda.tf)<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#Step_3_Deploy_the_Terraform_Configuration\" title=\"Step 3: Deploy the Terraform Configuration\">Step 3: Deploy the Terraform Configuration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#Step_4_Triggering_the_Pipeline\" title=\"Step 4: Triggering the Pipeline\">Step 4: Triggering the Pipeline<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#Summary\" title=\"Summary\">Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Overview_of_the_Steps\"><\/span><strong>Overview of the Steps:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Set up an S3 bucket for the content.<\/li>\n\n\n\n<li>Set up a CloudFront distribution for caching and serving the content.<\/li>\n\n\n\n<li>Set up an AWS CodePipeline with:\n<ul class=\"wp-block-list\">\n<li>Source (GitHub)<\/li>\n\n\n\n<li>Build (optional, for content build)<\/li>\n\n\n\n<li>Deploy (S3 and CloudFront invalidation)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Use Terraform to automate the above steps.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Create_the_Terraform_Project_Directory\"><\/span><strong>Step 1: Create the Terraform Project Directory<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a directory to store your Terraform configuration files.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bashCopy code<code>mkdir my-ci-cd-pipeline\ncd my-ci-cd-pipeline\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Set_Up_Terraform_Configuration_Files\"><\/span><strong>Step 2: Set Up Terraform Configuration Files<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create the following Terraform files in the project directory:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Provider_Configuration_providertf\"><\/span><strong>1. Provider Configuration (<code>provider.tf<\/code>)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file sets up the AWS provider for Terraform.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hclCopy code<code>provider \"aws\" {\n  region = \"us-east-1\"  # Change to your desired region\n}\n\nprovider \"github\" {\n  token = \"&lt;your-github-token&gt;\"\n  owner = \"&lt;your-github-username&gt;\"\n}\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Note: Replace <code>&lt;your-github-token&gt;<\/code> with your GitHub personal access token and <code>&lt;your-github-username&gt;<\/code> with your GitHub username.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_S3_Bucket_s3tf\"><\/span><strong>2. S3 Bucket (<code>s3.tf<\/code>)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file defines the S3 bucket where your content will be stored.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hclCopy code<code>resource \"aws_s3_bucket\" \"content_bucket\" {\n  bucket = \"my-content-bucket\"  # Replace with your unique bucket name\n  acl    = \"public-read\"\n}\n\nresource \"aws_s3_bucket_object\" \"content_object\" {\n  bucket = aws_s3_bucket.content_bucket.bucket\n  key    = \"index.html\"  # Example content file\n  source = \"index.html\"  # Path to the local file (e.g., content)\n  acl    = \"public-read\"\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_CloudFront_Distribution_cloudfronttf\"><\/span><strong>3. CloudFront Distribution (<code>cloudfront.tf<\/code>)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file creates the CloudFront distribution.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hclCopy code<code>resource \"aws_cloudfront_distribution\" \"content_distribution\" {\n  origin {\n    domain_name = aws_s3_bucket.content_bucket.bucket_regional_domain_name\n    origin_id   = \"S3-my-content-bucket\"\n  }\n\n  enabled             = true\n  is_ipv6_enabled     = true\n  default_root_object = \"index.html\"\n\n  viewer_certificate {\n    cloudfront_default_certificate = true\n  }\n\n  default_cache_behavior {\n    target_origin_id       = \"S3-my-content-bucket\"\n    viewer_protocol_policy = \"allow-all\"\n    allowed_methods {\n      items = [\"GET\", \"HEAD\"]\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_GitHub_Webhook_for_CodePipeline_github_webhooktf\"><\/span><strong>4. GitHub Webhook for CodePipeline (<code>github_webhook.tf<\/code>)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file sets up the webhook in GitHub to trigger the pipeline.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hclCopy code<code>resource \"aws_codepipeline\" \"pipeline\" {\n  name     = \"my-cicd-pipeline\"\n  role_arn = aws_iam_role.pipeline_role.arn\n\n  artifact_store {\n    location = aws_s3_bucket.content_bucket.bucket\n    type     = \"S3\"\n  }\n\n  stage {\n    name = \"Source\"\n\n    action {\n      name             = \"GitHub_Source\"\n      category         = \"Source\"\n      owner            = \"ThirdParty\"\n      provider         = \"GitHub\"\n      version          = \"1\"\n      output_artifacts = [\"SourceOutput\"]\n      configuration = {\n        \"Owner\"    = \"&lt;your-github-username&gt;\"\n        \"Repo\"     = \"&lt;your-repository-name&gt;\"\n        \"Branch\"   = \"main\"\n        \"OAuthToken\" = \"&lt;your-oauth-token&gt;\"\n      }\n    }\n  }\n\n  stage {\n    name = \"Deploy\"\n\n    action {\n      name             = \"Deploy_to_S3\"\n      category         = \"Deploy\"\n      owner            = \"AWS\"\n      provider         = \"S3\"\n      input_artifacts  = [\"SourceOutput\"]\n      output_artifacts = []\n      configuration = {\n        \"BucketName\" = aws_s3_bucket.content_bucket.bucket\n        \"Extract\"    = \"true\"\n      }\n    }\n\n    action {\n      name             = \"Invalidate_CloudFront\"\n      category         = \"Invoke\"\n      owner            = \"AWS\"\n      provider         = \"Lambda\"\n      input_artifacts  = []\n      configuration = {\n        \"FunctionName\" = aws_lambda_function.invalidate_function.arn\n      }\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Note: Replace <code>&lt;your-github-username&gt;<\/code>, <code>&lt;your-repository-name&gt;<\/code>, and <code>&lt;your-oauth-token&gt;<\/code> with appropriate values.<\/p>\n<\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_IAM_Role_and_Policies_iamtf\"><\/span><strong>5. IAM Role and Policies (<code>iam.tf<\/code>)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file defines the IAM role for the pipeline.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hclCopy code<code>resource \"aws_iam_role\" \"pipeline_role\" {\n  name = \"codepipeline_role\"\n\n  assume_role_policy = jsonencode({\n    Version = \"2012-10-17\"\n    Statement = [{\n      Action    = \"sts:AssumeRole\"\n      Effect    = \"Allow\"\n      Principal = {\n        Service = \"codepipeline.amazonaws.com\"\n      }\n    }]\n  })\n}\n\nresource \"aws_iam_policy\" \"codepipeline_policy\" {\n  name        = \"codepipeline-policy\"\n  description = \"Policy for CodePipeline access\"\n\n  policy = jsonencode({\n    Version = \"2012-10-17\"\n    Statement = [\n      {\n        Action    = [\"s3:GetObject\", \"s3:PutObject\"]\n        Effect    = \"Allow\"\n        Resource  = \"${aws_s3_bucket.content_bucket.arn}\/*\"\n      },\n      {\n        Action    = \"cloudfront:CreateInvalidation\"\n        Effect    = \"Allow\"\n        Resource  = aws_cloudfront_distribution.content_distribution.arn\n      }\n    ]\n  })\n}\n\nresource \"aws_iam_role_policy_attachment\" \"pipeline_policy_attach\" {\n  policy_arn = aws_iam_policy.codepipeline_policy.arn\n  role_arn   = aws_iam_role.pipeline_role.arn\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Lambda_Function_for_CloudFront_Invalidation_lambdatf\"><\/span><strong>6. Lambda Function for CloudFront Invalidation (<code>lambda.tf<\/code>)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the Lambda function code that invalidates the CloudFront cache when the content is updated.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">hclCopy code<code>resource \"aws_lambda_function\" \"invalidate_function\" {\n  filename      = \"lambda.zip\"\n  function_name = \"InvalidateCloudFront\"\n  role          = aws_iam_role.lambda_execution_role.arn\n  handler       = \"index.handler\"\n  runtime       = \"nodejs14.x\"\n\n  source_code_hash = filebase64sha256(\"lambda.zip\")\n}\n\nresource \"aws_iam_role\" \"lambda_execution_role\" {\n  name = \"lambda_execution_role\"\n\n  assume_role_policy = jsonencode({\n    Version = \"2012-10-17\"\n    Statement = [{\n      Action    = \"sts:AssumeRole\"\n      Effect    = \"Allow\"\n      Principal = {\n        Service = \"lambda.amazonaws.com\"\n      }\n    }]\n  })\n}\n\nresource \"aws_iam_policy\" \"lambda_policy\" {\n  name        = \"LambdaCloudFrontPolicy\"\n  description = \"Lambda policy to invalidate CloudFront cache\"\n\n  policy = jsonencode({\n    Version = \"2012-10-17\"\n    Statement = [\n      {\n        Action    = \"cloudfront:CreateInvalidation\"\n        Effect    = \"Allow\"\n        Resource  = aws_cloudfront_distribution.content_distribution.arn\n      }\n    ]\n  })\n}\n\nresource \"aws_iam_role_policy_attachment\" \"lambda_policy_attachment\" {\n  role       = aws_iam_role.lambda_execution_role.name\n  policy_arn = aws_iam_policy.lambda_policy.arn\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Lambda Function Code (<code>index.js<\/code>)<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">jsCopy code<code>const AWS = require('aws-sdk');\nconst cloudfront = new AWS.CloudFront();\n\nexports.handler = async (event) =&gt; {\n    const params = {\n        DistributionId: 'YOUR_CLOUDFRONT_DISTRIBUTION_ID', \/\/ Replace with your CloudFront Distribution ID\n        InvalidationBatch: {\n            Paths: {\n                Quantity: 1,\n                Items: [\"\/*\"]  \/\/ Invalidate all content\n            },\n            CallerReference: `invalidate-${Date.now()}`\n        }\n    };\n    \n    try {\n        const result = await cloudfront.createInvalidation(params).promise();\n        console.log(\"Invalidation result:\", result);\n        return {\n            statusCode: 200,\n            body: JSON.stringify('Invalidation success'),\n        };\n    } catch (error) {\n        console.log(\"Error invalidating CloudFront:\", error);\n        return {\n            statusCode: 500,\n            body: JSON.stringify('Invalidation failed'),\n        };\n    }\n};\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note<\/strong>: Create a <code>.zip<\/code> file of the <code>index.js<\/code> Lambda code and upload it as <code>lambda.zip<\/code>.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Deploy_the_Terraform_Configuration\"><\/span><strong>Step 3: Deploy the Terraform Configuration<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Initialize the Terraform project:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">bashCopy code<code>terraform init\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Apply the configuration:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">bashCopy code<code>terraform apply\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This will create all the resources (S3 bucket, CloudFront distribution, CodePipeline, IAM roles, Lambda, etc.).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Triggering_the_Pipeline\"><\/span><strong>Step 4: Triggering the Pipeline<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once the Git repository is updated (i.e., new content is pushed), the pipeline will automatically be triggered by the GitHub webhook. It will deploy the new content to the S3 bucket, and the Lambda function will invalidate the CloudFront cache to reflect the new changes.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span><strong>Summary<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we created a CI\/CD pipeline using <strong>AWS CodePipeline<\/strong> to automatically deploy content to <strong>CloudFront<\/strong> from a Git repository. We used <strong>Terraform<\/strong> to automate the creation of resources such as S3, CloudFront, IAM roles, and Lambda functions. The key steps included setting up a webhook for GitHub to trigger the pipeline, creating stages for source, build (if needed), and deploy actions, and using Lambda for cache invalidation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a CI\/CD pipeline using AWS CodePipeline to push content to Amazon CloudFront when a Git repository is updated involves several steps. Below is a detailed process using Terraform to automate the infrastructure setup for this pipeline. The pipeline will: Overview of the Steps: Step 1: Create the Terraform Project Directory Create a directory to ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1580","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CI\/CD Pipeline for CloudFront on GIT Update - Learn System Administration<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CI\/CD Pipeline for CloudFront on GIT Update - Learn System Administration\" \/>\n<meta property=\"og:description\" content=\"Creating a CI\/CD pipeline using AWS CodePipeline to push content to Amazon CloudFront when a Git repository is updated involves several steps. Below is a detailed process using Terraform to automate the infrastructure setup for this pipeline. The pipeline will: Overview of the Steps: Step 1: Create the Terraform Project Directory Create a directory to ..Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn System Administration\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-13T12:29:23+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/\",\"url\":\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/\",\"name\":\"CI\/CD Pipeline for CloudFront on GIT Update - Learn System Administration\",\"isPartOf\":{\"@id\":\"https:\/\/learnsysadmin.com\/#website\"},\"datePublished\":\"2024-11-13T12:29:22+00:00\",\"dateModified\":\"2024-11-13T12:29:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/learnsysadmin.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CI\/CD Pipeline for CloudFront on GIT Update\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/learnsysadmin.com\/#website\",\"url\":\"https:\/\/learnsysadmin.com\/\",\"name\":\"Learn System Administration\",\"description\":\"Learn the basics\",\"publisher\":{\"@id\":\"https:\/\/learnsysadmin.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/learnsysadmin.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/learnsysadmin.com\/#organization\",\"name\":\"Learn System Administration\",\"url\":\"https:\/\/learnsysadmin.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/learnsysadmin.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/learnsysadmin.com\/wp-content\/uploads\/2023\/07\/icons8-admin-settings-male-100.png\",\"contentUrl\":\"https:\/\/learnsysadmin.com\/wp-content\/uploads\/2023\/07\/icons8-admin-settings-male-100.png\",\"width\":100,\"height\":100,\"caption\":\"Learn System Administration\"},\"image\":{\"@id\":\"https:\/\/learnsysadmin.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CI\/CD Pipeline for CloudFront on GIT Update - Learn System Administration","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/","og_locale":"en_US","og_type":"article","og_title":"CI\/CD Pipeline for CloudFront on GIT Update - Learn System Administration","og_description":"Creating a CI\/CD pipeline using AWS CodePipeline to push content to Amazon CloudFront when a Git repository is updated involves several steps. Below is a detailed process using Terraform to automate the infrastructure setup for this pipeline. The pipeline will: Overview of the Steps: Step 1: Create the Terraform Project Directory Create a directory to ..Read more","og_url":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/","og_site_name":"Learn System Administration","article_modified_time":"2024-11-13T12:29:23+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/","url":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/","name":"CI\/CD Pipeline for CloudFront on GIT Update - Learn System Administration","isPartOf":{"@id":"https:\/\/learnsysadmin.com\/#website"},"datePublished":"2024-11-13T12:29:22+00:00","dateModified":"2024-11-13T12:29:23+00:00","breadcrumb":{"@id":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/learnsysadmin.com\/index.php\/ci-cd-pipeline-for-cloudfront-on-git-update\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/learnsysadmin.com\/"},{"@type":"ListItem","position":2,"name":"CI\/CD Pipeline for CloudFront on GIT Update"}]},{"@type":"WebSite","@id":"https:\/\/learnsysadmin.com\/#website","url":"https:\/\/learnsysadmin.com\/","name":"Learn System Administration","description":"Learn the basics","publisher":{"@id":"https:\/\/learnsysadmin.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/learnsysadmin.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/learnsysadmin.com\/#organization","name":"Learn System Administration","url":"https:\/\/learnsysadmin.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/learnsysadmin.com\/#\/schema\/logo\/image\/","url":"https:\/\/learnsysadmin.com\/wp-content\/uploads\/2023\/07\/icons8-admin-settings-male-100.png","contentUrl":"https:\/\/learnsysadmin.com\/wp-content\/uploads\/2023\/07\/icons8-admin-settings-male-100.png","width":100,"height":100,"caption":"Learn System Administration"},"image":{"@id":"https:\/\/learnsysadmin.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/pages\/1580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/comments?post=1580"}],"version-history":[{"count":1,"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/pages\/1580\/revisions"}],"predecessor-version":[{"id":1581,"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/pages\/1580\/revisions\/1581"}],"wp:attachment":[{"href":"https:\/\/learnsysadmin.com\/index.php\/wp-json\/wp\/v2\/media?parent=1580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}