id
stringlengths
14
16
text
stringlengths
1
2.43k
source
stringlengths
99
229
437e48c28b16-7
| Pipeline tag values | Any combination of Unicode letters, numbers, spaces, and allowed characters in UTF\-8 between 1 and 256 characters in length\. Allowed characters are \+ \- = \. \_ : / @ A key can have only one value, but many keys can have the same value\. A tag cannot: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/limits.html) | | Uniqueness of names | Within a single AWS account, each pipeline you create in an AWS Region must have a unique name\. You can reuse names for pipelines in different AWS Regions\. Stage names must be unique within a pipeline\. Action names must be unique within a stage\. | | Variable quotas | There is a maximum size limit of 122880 bytes for all output variables combined for a particular action\. There is a maximum size limit of 100 KB for the total resolved action configuration for a particular action\. Output variable names are case sensitive\. Namespaces are case sensitive\. Allowed characters include: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/limits.html) |
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/limits.md
22d4299df1e4-0
The following information might help you troubleshoot common issues in AWS CodePipeline\. **Topics** + [Pipeline error: A pipeline configured with AWS Elastic Beanstalk returns an error message: "Deployment failed\. The provided role does not have sufficient permissions: Service:AmazonElasticLoadBalancing"](#troubleshooting-aeb1) + [Deployment error: A pipeline configured with an AWS Elastic Beanstalk deploy action hangs instead of failing if the "DescribeEvents" permission is missing](#troubleshooting-aeb2) + [Pipeline error: A source action returns the insufficient permissions message: "Could not access the CodeCommit repository `repository-name`\. Make sure that the pipeline IAM role has sufficient permissions to access the repository\."](#troubleshooting-service-role-permissions) + [Pipeline error: A Jenkins build or test action runs for a long time and then fails due to lack of credentials or permissions](#troubleshooting-jen1) + [Pipeline error: My GitHub source stage contains Git submodules, but CodePipeline doesn't initialize them](#troubleshooting-gs1) + [Pipeline error: I receive a pipeline error that says: "Could not access the GitHub repository" or "Unable to connect to the GitHub repository"](#troubleshooting-gs2) + [Pipeline error: A pipeline created in one AWS Region using a bucket created in another AWS Region returns an "InternalError" with the code "JobFailed"](#troubleshooting-reg-1)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
22d4299df1e4-1
+ [Deployment error: A ZIP file that contains a WAR file is deployed successfully to AWS Elastic Beanstalk, but the application URL reports a 404 not found error](#troubleshooting-aeb2) + [Pipeline artifact folder names appear to be truncated](#troubleshooting-truncated-artifacts) + [Pipeline error: A deployment with the CodeDeployToECS action returns an error message: "Exception while trying to read the task definition artifact file from: <source artifact name>"](#troubleshooting-ecstocodedeploy-size) + [Need help with a different issue?](#troubleshooting-other)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
81b313ec2185-0
**Problem:** The service role for CodePipeline does not have sufficient permissions for AWS Elastic Beanstalk, including, but not limited to, some operations in Elastic Load Balancing\. The service role for CodePipeline was updated on August 6, 2015 to address this issue\. Customers who created their service role before this date must modify the policy statement for their service role to add the required permissions\. **Possible fixes:** The easiest solution is to edit the policy statement for your service role as detailed in [Add permissions to the CodePipeline service role](security-iam.md#how-to-update-role-new-services)\. After you apply the edited policy, follow the steps in [Start a pipeline manually in AWS CodePipeline](pipelines-rerun-manually.md) to manually rerun any pipelines that use Elastic Beanstalk\. Depending on your security needs, you can modify the permissions in other ways, too\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
c03d84f9170b-0
**Problem:** The service role for CodePipeline must include the `"elasticbeanstalk:DescribeEvents"` action for any pipelines that use AWS Elastic Beanstalk\. Without this permission, AWS Elastic Beanstalk deploy actions hang without failing or indicating an error\. If this action is missing from your service role, then CodePipeline does not have permissions to run the pipeline deployment stage in AWS Elastic Beanstalk on your behalf\. **Possible fixes:** Review your CodePipeline service role\. If the `"elasticbeanstalk:DescribeEvents"` action is missing, use the steps in [Add permissions to the CodePipeline service role](security-iam.md#how-to-update-role-new-services) to add it using the **Edit Policy** feature in the IAM console\. After you apply the edited policy, follow the steps in [Start a pipeline manually in AWS CodePipeline](pipelines-rerun-manually.md) to manually rerun any pipelines that use Elastic Beanstalk\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
993a827fc19e-0
**Problem:** The service role for CodePipeline does not have sufficient permissions for CodeCommit and likely was created before support for using CodeCommit repositories was added on April 18, 2016\. Customers who created their service role before this date must modify the policy statement for their service role to add the required permissions\. **Possible fixes:** Add the required permissions for CodeCommit to your CodePipeline service role's policy\. For more information, see [Add permissions to the CodePipeline service role](security-iam.md#how-to-update-role-new-services)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
d1baa54ff5a8-0
**Problem:** If the Jenkins server is installed on an Amazon EC2 instance, the instance might not have been created with an instance role that has the permissions required for CodePipeline\. If you are using an IAM user on a Jenkins server, an on\-premises instance, or an Amazon EC2 instance created without the required IAM role, the IAM user either does not have the required permissions, or the Jenkins server cannot access those credentials through the profile configured on the server\. **Possible fixes:** Make sure that Amazon EC2 instance role or IAM user is configured with the `AWSCodePipelineCustomActionAccess` managed policy or with the equivalent permissions\. For more information, see [AWS managed \(predefined\) policies for CodePipeline](managed-policies.md)\. If you are using an IAM user, make sure the AWS profile configured on the instance uses the IAM user configured with the correct permissions\. You might have to provide the IAM user credentials you configured for integration between Jenkins and CodePipeline directly into the Jenkins UI\. This is not a recommended best practice\. If you must do so, be sure the Jenkins server is secured and uses HTTPS instead of HTTP\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
d470a7b86c9f-0
**Problem:** CodePipeline does not support git submodules\. CodePipeline relies on the archive link API from GitHub, which does not support submodules\. **Possible fixes:** Consider cloning the GitHub repository directly as part of a separate script\. For example, you could include a clone action in a Jenkins script\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
70699f4ab264-0
**Problem:** CodePipeline uses OAuth tokens to integrate with GitHub\. When you create a pipeline with a GitHub source provider, CodePipeline manages your GitHub credentials by creating a default OAuth token\. When your pipeline connects to the repository, it uses GitHub credentials to connect to GitHub\. The OAuth token credentials are managed by CodePipeline\. You do not view or manage the token in any way\. The other type of credentials you can use to connect to GitHub are personal access tokens, which are created by you instead of by OAuth apps\. Personal access tokens are managed by you and not by CodePipeline\. If these permissions have been revoked or otherwise disabled, then the pipeline fails when it cannot use the GitHub token to connect to the repository\. It is a security best practice to rotate your personal access token on a regular basis\. For more information, see [Use GitHub and the CodePipeline CLI to create and rotate your GitHub personal access token on a regular basis](GitHub-authentication.md#GitHub-rotate-personal-token-CLI)\. **Possible fixes:** If CodePipeline is unable to connect to the GitHub repository, there are two troubleshooting options: + You might simply need to reconnect your pipeline to the repository manually\. You might have revoked the permissions of the OAuth token for CodePipeline and they just need to be restored\. To do this, see the steps below\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
70699f4ab264-1
+ You might need to change your default OAuth token to a personal access token\. The number of OAuth tokens is limited\. For more information, see [the GitHub documentation](https://developer.github.com/v3/oauth/)\. If CodePipeline reaches that limit, older tokens stop working, and actions in pipelines that rely on that token fail\. 1. Check to see if the permissions for CodePipeline have been revoked\. For the steps to check the **Authorized OAuth Apps** list in GitHub, see [View your authorized OAuth apps](GitHub-authentication.md#GitHub-view-oauth-token)\. If you do not see CodePipeline in the list, you must use the console to reconnect your pipeline to GitHub\. 1. Open your pipeline in the console and choose **Edit**\. On the source stage that contains your GitHub source action, choose **Edit stage**\. 1. On the GitHub source action, choose the edit icon\. 1. On the **Edit action** page, choose **Connect to GitHub** to restore the authorization\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
70699f4ab264-2
1. On the **Edit action** page, choose **Connect to GitHub** to restore the authorization\. ![\[A pipeline contains stages that contain actions, separated by transitions that can be disabled and enabled.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/images/button-connect-to-github.png)![\[A pipeline contains stages that contain actions, separated by transitions that can be disabled and enabled.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/)![\[A pipeline contains stages that contain actions, separated by transitions that can be disabled and enabled.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/) If prompted, you might need to re\-enter the **Repository** and **Branch** for your action\. Choose **Done**\. Choose **Done** on the stage editing page, and then choose **Save** on the pipeline editing page\. Run the pipeline\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
70699f4ab264-3
1. If this does not correct the error but you can see CodePipeline in the **Authorized OAuth Apps** list in GitHub, you might have exceeded the allowed number of tokens\. To fix this issue, you can manually configure one OAuth token as a personal access token, and then configure all pipelines in your AWS account to use that token\. For more information, see [Configure your pipeline to use a personal access token \(GitHub and CLI\)](GitHub-create-personal-token-CLI.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
5ab35a306a8a-0
**Problem:** The download of an artifact stored in an Amazon S3 bucket will fail if the pipeline and bucket are created in different AWS Regions\. **Possible fixes:** Make sure the Amazon S3 bucket where your artifact is stored is in the same AWS Region as the pipeline you have created\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
5088866dd567-0
**Problem:** A WAR file is deployed successfully to an AWS Elastic Beanstalk environment, but the application URL returns a 404 Not Found error\. **Possible fixes:** AWS Elastic Beanstalk can unpack a ZIP file, but not a WAR file contained in a ZIP file\. Instead of specifying a WAR file in your `buildspec.yml` file, specify a folder that contains the content to be deployed\. For example: ``` version: 0.2 phases: post_build: commands: - mvn package - mv target/my-web-app ./ artifacts: files: - my-web-app/**/* discard-paths: yes ``` For an example, see [AWS Elastic Beanstalk Sample for CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/sample-elastic-beanstalk.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
0215bf1499b9-0
**Problem:** When you view pipeline artifact names in CodePipeline, the names appear to be truncated\. This can make the names appear to be similar or seem to no longer contain the entire pipeline name\. **Explanation:** CodePipeline truncates artifact names to ensure that the full Amazon S3 path does not exceed policy size limits when CodePipeline generates temporary credentials for job workers\. Even though the artifact name appears to be truncated, CodePipeline maps to the artifact bucket in a way that is not affected by artifacts with truncated names\. The pipeline can function normally\. This is not an issue with the folder or artifacts\. There is a 100\-character limit to pipeline names\. Although the artifact folder name might appear to be shortened, it is still unique for your pipeline\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
e373572ad256-0
**Problem:** The maximum artifact ZIP size in the CodePipeline deploy action to ECS through CodeDeploy \(the `CodeDeployToECS` action\) is 3 MB\. The following error message is returned when artifact sizes exceed 3 MB: Exception while trying to read the task definition artifact file from: <source artifact name> **Possible fixes:** Create an artifact with a compressed size less than 3 MB\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
7973d33821a0-0
Try these other resources: + Contact [AWS Support](https://aws.amazon.com/contact-us/)\. + Ask a question in the [CodePipeline forum](https://forums.aws.amazon.com/forum.jspa?forumID=197)\. + [Request a quota increase](https://console.aws.amazon.com/support/home#/case/create%3FissueType=service-limit-increase)\. For more information, see [Quotas in AWS CodePipeline](limits.md)\. **Note** It can take up to two weeks to process requests for a quota increase\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/troubleshooting.md
32878c64fad0-0
In AWS CodePipeline, an action is part of the sequence in a stage of a pipeline\. It is a task performed on the artifact in that stage\. Pipeline actions occur in a specified order, in sequence or in parallel, as determined in the configuration of the stage\. CodePipeline provides support for six types of actions: + Source + Build + Test + Deploy + Approval + Invoke For information about the AWS services and partner products and services you can integrate into your pipeline based on action type, see [Integrations with CodePipeline action types](integrations-action-type.md)\. **Topics** + [Create a custom action for a pipeline](actions-create-custom-action.md) + [Tag a custom action in CodePipeline](customactions-tag.md) + [Invoke a Lambda function in a pipeline](actions-invoke-lambda-function.md) + [Retry a failed action](actions-retry.md) + [Manage approval actions in pipelines](approvals.md) + [Add a cross\-Region action to a pipeline](actions-create-cross-region.md) + [Working with variables](actions-variables.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions.md
02a51b4ab415-0
In AWS CodePipeline, you can add an approval action to a stage in a pipeline at the point where you want the pipeline execution to stop so that someone with the required AWS Identity and Access Management permissions can approve or reject the action\. If the action is approved, the pipeline execution resumes\. If the action is rejected—or if no one approves or rejects the action within seven days of the pipeline reaching the action and stopping—the result is the same as an action failing, and the pipeline execution does not continue\. You might use manual approvals for these reasons: + You want someone to perform a code review or change management review before a revision is allowed into the next stage of a pipeline\. + You want someone to perform manual quality assurance testing on the latest version of an application, or to confirm the integrity of a build artifact, before it is released\. + You want someone to review new or updated text before it is published to a company website\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals.md
fe75802782a1-0
CodePipeline provides three configuration options you can use to tell approvers about the approval action\. **Publish Approval Notifications** You can configure an approval action to publish a message to an Amazon Simple Notification Service topic when the pipeline stops at the action\. Amazon SNS delivers the message to every endpoint subscribed to the topic\. You must use a topic created in the same AWS Region as the pipeline that will include the approval action\. When you create a topic, we recommend you give it a name that will identify its purpose, in formats such as `MyFirstPipeline-us-east-2-approval`\. When you publish approval notifications to Amazon SNS topics, you can choose from formats such as email or SMS recipients, SQS queues, HTTP/HTTPS endpoints, or AWS Lambda functions you invoke using Amazon SNS\. For information about Amazon SNS topic notifications, see the following topics: + [What Is Amazon Simple Notification Service?](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) + [Create a Topic in Amazon SNS](https://docs.aws.amazon.com/sns/latest/dg/CreateTopic.html) + [Sending Amazon SNS Messages to Amazon SQS Queues](https://docs.aws.amazon.com/sns/latest/dg/SendMessageToSQS.html)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals.md
fe75802782a1-1
+ [Subscribing a Queue to an Amazon SNS Topic](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqssubscribe.html) + [Sending Amazon SNS Messages to HTTP/HTTPS Endpoints](https://docs.aws.amazon.com/sns/latest/dg/SendMessageToHttp.html) + [Invoking Lambda Functions Using Amazon SNS Notifications](https://docs.aws.amazon.com/sns/latest/dg/sns-lambda.html) For the structure of the JSON data generated for an approval action notification, see [JSON data format for manual approval notifications in CodePipeline](approvals-json-format.md)\. **Specify a URL for Review** As part of the configuration of the approval action, you can specify a URL to be reviewed\. The URL might be a link to a web application you want approvers to test or a page with more information about your approval request\. The URL is included in the notification that is published to the Amazon SNS topic\. Approvers can use the console or CLI to view it\. **Enter Comments for Approvers** When you create an approval action, you can also add comments that are displayed to those who receive the notifications or those who view the action in the console or CLI response\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals.md
fe75802782a1-2
**No Configuration Options** You can also choose not to configure any of these three options\. You might not need them if, for example, you can notify someone directly that the action is ready for their review, or you simply want the pipeline to stop until you decide to approve the action yourself\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals.md
952ba0201424-0
The following is an overview for setting up and using manual approvals\. 1. You grant the IAM permissions required for approving or rejecting approval actions to one or more IAM users in your organization\. 1. \(Optional\) If you are using Amazon SNS notifications, you ensure that the service role you use in your CodePipeline operations has permission to access Amazon SNS resources\. 1. \(Optional\) If you are using Amazon SNS notifications, you create an Amazon SNS topic and add one or more subscribers or endpoints to it\. 1. When you use the AWS CLI to create the pipeline or after you have used the CLI or console to create the pipeline, you add an approval action to a stage in the pipeline\. If you are using notifications, you include the Amazon Resource Name \(ARN\) of the Amazon SNS topic in the configuration of the action\. \(An ARN is a unique identifier for an Amazon resource\. ARNs for Amazon SNS topics are structured like *arn:aws:sns:us\-east\-2:80398EXAMPLE:MyApprovalTopic*\. For more information, see [Amazon Resource Names \(ARNs\) and AWS Service Namespaces](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) in the *Amazon Web Services General Reference*\.\)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals.md
952ba0201424-1
1. The pipeline stops when it reaches the approval action\. If an Amazon SNS topic ARN was included in the configuration of the action, a notification is published to the Amazon SNS topic, and a message is delivered to any subscribers to the topic or subscribed endpoints, with a link to review the approval action in the console\. 1. An approver examines the target URL and reviews comments, if any\. 1. Using the console, CLI, or SDK, the approver provides a summary comment and submits a response: + Approved: The pipeline execution resumes\. + Rejected: The stage status is changed to "Failed" and the pipeline execution does not resume\. If no response is submitted within seven days, the action is marked as "Failed\."
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals.md
8d419c94945a-0
AWS CodePipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your software\. You can quickly model and configure the different stages of a software release process\. CodePipeline automates the steps required to release your software changes continuously\. For information about pricing for CodePipeline, see [Pricing](http://aws.amazon.com/codepipeline/pricing/)\. **Topics** + [Continuous delivery and continuous integration](concepts-continuous-delivery-integration.md) + [What can I do with CodePipeline?](welcome-what-can-I-do.md) + [A quick look at CodePipeline](welcome-introducing.md) + [How do I get started with CodePipeline?](welcome-get-started.md) + [We want to hear from you](welcome-contact-us.md) + [CodePipeline concepts](concepts.md) + [DevOps pipeline example](concepts-devops-example.md) + [How pipeline executions work](concepts-how-it-works.md) + [Input and output artifacts](welcome-introducing-artifacts.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/welcome.md
9ef9d221530f-0
AWS CodePipeline conforms to the AWS [shared responsibility model](http://aws.amazon.com/compliance/shared-responsibility-model/), which includes regulations and guidelines for data protection\. AWS is responsible for protecting the global infrastructure that runs all of the AWS services\. AWS maintains control over data hosted on this infrastructure, including the security configuration controls for handling customer content and personal data\. AWS customers and APN partners, acting either as data controllers or data processors, are responsible for any personal data that they put in the AWS Cloud\. For data protection purposes, we recommend that you protect AWS account credentials and set up individual user accounts with AWS Identity and Access Management \(IAM\) so that each user is given only the permissions required to fulfill their job duties\. We also recommend that you secure your data in the following ways: + Use multi\-factor authentication \(MFA\) with each account\. + Use SSL/TLS to communicate with AWS resources\. + Set up API and user activity logging with AWS CloudTrail\. + Use AWS encryption solutions, along with all default security controls in AWS services\. + Use advanced managed security services such as Amazon Macie, which assists in discovering and securing personal data that is stored in Amazon S3\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
9ef9d221530f-1
+ Use advanced managed security services such as Amazon Macie, which assists in discovering and securing personal data that is stored in Amazon S3\. We strongly recommend that you never put sensitive identifying information, such as your customers' account numbers, into free\-form fields such as a **Name** field\. This includes when you work with CodePipeline or other AWS services using the console, API, AWS CLI, or AWS SDKs\. Any data that you enter into CodePipeline or other services might get picked up for inclusion in diagnostic logs\. When you provide a URL to an external server, don't include credentials information in the URL to validate your request to that server\. For more information about data protection, see the [AWS Shared Responsibility Model and GDPR](http://aws.amazon.com/blogs/security/the-aws-shared-responsibility-model-and-gdpr/) blog post on the *AWS Security Blog*\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
c63eb4210345-0
Amazon VPC is an AWS service that you can use to launch AWS resources in a virtual network \(*virtual private cloud*\) that you define\. CodePipeline supports Amazon VPC endpoints powered by AWS PrivateLink, an AWS technology that facilitates private communication between AWS services using an elastic network interface with private IP addresses\. This means you can connect directly to CodePipeline through a private endpoint in your VPC, keeping all traffic inside your VPC and the AWS network\. Previously, applications running inside a VPC required internet access to connect to CodePipeline\. With a VPC, you have control over your network settings, such as: + IP address range\. + Subnets\. + Route tables\. + Network gateways\. To connect your VPC to CodePipeline, you define an interface VPC endpoint for CodePipeline\. This type of endpoint makes it possible for you to connect your VPC to AWS services\. The endpoint provides reliable, scalable connectivity to CodePipeline without requiring an internet gateway, network address translation \(NAT\) instance, or VPN connection\. For information about setting up a VPC, see the [VPC User Guide](https://docs.aws.amazon.com/vpc/latest/userguide/)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
848ff837f9ca-0
Data in CodePipeline is encrypted at rest using service\-owned KMS keys\. Code artifacts are stored in a customer\-owned S3 bucket and encrypted with either the default AWS managed SSE\-KMS encryption key or a customer managed SSE\-KMS key\. For more information, see [Configure server\-side encryption for artifacts stored in Amazon S3 for CodePipeline](S3-artifact-encryption.md)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
b8c65f751740-0
All service to service communication is encrypted in transit using SSL/TLS\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
c0176fe7422d-0
If the customer chooses the default option for encrypting code artifacts, CodePipeline uses the default AWS managed SSE\-KMS encryption key\. Customers cannot change or delete this AWS managed key\. If customers are using a customer managed key \(CMK\) in AWS KMS to encrypt or decrypt artifacts in the S3 bucket, they can change or rotate this key as necessary\. **Important** CodePipeline only supports symmetric customer master keys \(CMKs\)\. Do not use an asymmetric CMK to encrypt the data in your S3 bucket\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
aaff7e2dc5a6-0
This section describes data protection configuration for the following: + S3 artifacts server\-side encryption \(SSE\)\. + GitHub personal access tokens\. + Secret parameter tracking in AWS Secrets Manager\. **Topics** + [Configure server\-side encryption for artifacts stored in Amazon S3 for CodePipeline](S3-artifact-encryption.md) + [Configure GitHub authentication](GitHub-authentication.md) + [Use AWS Secrets Manager to track database passwords or third\-party API keys](parameter-store-encryption.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/data-protection.md
0aca384a3086-0
[AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/) is a compute service that lets you run code without provisioning or managing servers\. You can create Lambda functions and add them as actions in your pipelines\. Because Lambda allows you to write functions to perform almost any task, you can customize the way your pipeline works\. **Note** Creating and running Lambda functions might result in charges to your AWS account\. For more information, see [Pricing](http://aws.amazon.com/lambda/pricing/)\. Here are some ways Lambda functions can be used in pipelines: + To create resources on demand in one stage of a pipeline using AWS CloudFormation and delete them in another stage\. + To deploy application versions with zero downtime in AWS Elastic Beanstalk with a Lambda function that swaps CNAME values\. + To deploy to Amazon ECS Docker instances\. + To back up resources before building or deploying by creating an AMI snapshot\. + To add integration with third\-party products to your pipeline, such as posting messages to an IRC client\. This topic assumes you are familiar with AWS CodePipeline and AWS Lambda and know how to create pipelines, functions, and the IAM policies and roles on which they depend\. This topic shows you how to: + Create a Lambda function that tests whether a webpage was deployed successfully\. + Configure the CodePipeline and Lambda execution roles and the permissions required to run the function as part of the pipeline\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0aca384a3086-1
+ Configure the CodePipeline and Lambda execution roles and the permissions required to run the function as part of the pipeline\. + Edit a pipeline to add the Lambda function as an action\. + Test the action by manually releasing a change\. This topic includes sample functions to demonstrate the flexibility of working with Lambda functions in CodePipeline: + [Basic Lambda function](#LambdaSample1) + Creating a basic Lambda function to use with CodePipeline\. + Returning success or failure results to CodePipeline in the **Details** link for the action\. + [Sample Python function that uses an AWS CloudFormation template ](#actions-invoke-lambda-function-samples-python-cloudformation) + Using JSON\-encoded user parameters to pass multiple configuration values to the function \(`get_user_params`\)\. + Interacting with \.zip artifacts in an artifact bucket \(`get_template`\)\. + Using a continuation token to monitor a long\-running asynchronous process \(`continue_job_later`\)\. This allows the action to continue and the function to succeed even if it exceeds a fifteen\-minute runtime \(a limit in Lambda\)\. Each sample function includes information about the permissions you must add to the role\. For information about limits in AWS Lambda, see [Limits](https://docs.aws.amazon.com/lambda/latest/dg/limits.html) in the *AWS Lambda Developer Guide*\. **Important**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0aca384a3086-2
**Important** The sample code, roles, and policies included in this topic are examples only, and are provided as\-is\. **Topics** + [Step 1: Create a pipeline](#actions-invoke-lambda-function-create-test-pipeline) + [Step 2: Create the Lambda function](#actions-invoke-lambda-function-create-function) + [Step 3: Add the Lambda function to a pipeline in the CodePipeline console](#actions-invoke-lambda-function-add-action) + [Step 4: Test the pipeline with the Lambda function](#actions-invoke-lambda-function-test-function) + [Step 5: Next steps](#actions-invoke-lambda-function-next-steps) + [Example JSON event](#actions-invoke-lambda-function-json-event-example) + [Additional sample functions](#actions-invoke-lambda-function-samples)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
494571ab678e-0
In this step, you create a pipeline to which you later add the Lambda function\. This is the same pipeline you created in [CodePipeline tutorials](tutorials.md)\. If that pipeline is still configured for your account and is in the same Region where you plan to create the Lambda function, you can skip this step\. **To create the pipeline** 1. Follow the first three steps in [Tutorial: Create a simple pipeline \(S3 bucket\)](tutorials-simple-s3.md) to create an Amazon S3 bucket, CodeDeploy resources, and a two\-stage pipeline\. Choose the Amazon Linux option for your instance types\. You can use any name you want for the pipeline, but the steps in this topic use MyLambdaTestPipeline\. 1. On the status page for your pipeline, in the CodeDeploy action, choose **Details**\. On the deployment details page for the deployment group, choose an instance ID from the list\. 1. In the Amazon EC2 console, on the **Details** tab for the instance, copy the IP address in **Public IPv4 address** \(for example, **192\.0\.2\.4**\)\. You use this address as the target of the function in AWS Lambda\. **Note**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
494571ab678e-1
**Note** The default service role policy for CodePipeline includes the Lambda permissions required to invoke the function\. However, if you have modified the default service role or selected a different one, make sure the policy for the role allows the `lambda:InvokeFunction` and `lambda:ListFunctions` permissions\. Otherwise, pipelines that include Lambda actions fail\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-0
In this step, you create a Lambda function that makes an HTTP request and checks for a line of text on a webpage\. As part of this step, you must also create an IAM policy and Lambda execution role\. For more information, see [Permissions Model](https://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role) in the *AWS Lambda Developer Guide*\. **To create the execution role** 1. Sign in to the AWS Management Console and open the IAM console at [https://console\.aws\.amazon\.com/iam/](https://console.aws.amazon.com/iam/)\. 1. Choose **Policies**, and then choose **Create Policy**\. Choose the **JSON** tab, and then paste the following policy into the field\. ``` { "Version": "2012-10-17", "Statement": [ { "Action": [ "logs:*" ], "Effect": "Allow", "Resource": "arn:aws:logs:*:*:*" }, { "Action": [ "codepipeline:PutJobSuccessResult", "codepipeline:PutJobFailureResult" ],
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-1
"codepipeline:PutJobSuccessResult", "codepipeline:PutJobFailureResult" ], "Effect": "Allow", "Resource": "*" } ] } ``` 1. Choose **Review policy**\. 1. On the **Review policy** page, in **Name**, type a name for the policy \(for example, **CodePipelineLambdaExecPolicy**\)\. In **Description**, enter **Enables Lambda to execute code**\. Choose **Create Policy**\. **Note** These are the minimum permissions required for a Lambda function to interoperate with CodePipeline and Amazon CloudWatch\. If you want to expand this policy to allow functions that interact with other AWS resources, you should modify this policy to allow the actions required by those Lambda functions\. 1. On the policy dashboard page, choose **Roles**, and then choose **Create role**\. 1. On the **Create role** page, choose **AWS service**\. Choose **Lambda**, and then choose **Next: Permissions**\. 1. On the **Attach permissions policies** page, select the check box next to **CodePipelineLambdaExecPolicy**, and then choose **Next: Tags**\. Choose **Next: Review**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-2
1. On the **Review** page, in **Role name**, enter the name, and then choose **Create role**\.<a name="LambdaSample1"></a> **To create the sample Lambda function to use with CodePipeline** 1. Sign in to the AWS Management Console and open the AWS Lambda console at [https://console\.aws\.amazon\.com/lambda/](https://console.aws.amazon.com/lambda/)\. 1. On the **Functions** page, choose **Create function**\. **Note** If you see a **Welcome** page instead of the **Lambda** page, choose **Get Started Now**\. 1. On the **Create function** page, choose **Author from scratch**\. In **Function name**, enter a name for your Lambda function \(for example, **MyLambdaFunctionForAWSCodePipeline**\)\. In **Runtime**, choose **Node\.js 10\.x**\. 1. Under **Role**, select **Choose an existing role**\. In **Existing role**, choose your role, and then choose **Create function**\. The detail page for your created function opens\. 1. Copy the following code into the **Function code** box: **Note**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-3
1. Copy the following code into the **Function code** box: **Note** The event object, under the CodePipeline\.job key, contains the [job details](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_JobDetails.html)\. For a full example of the JSON event CodePipeline returns to Lambda, see [Example JSON event](#actions-invoke-lambda-function-json-event-example)\. ``` var assert = require('assert'); var AWS = require('aws-sdk'); var http = require('http'); exports.handler = function(event, context) { var codepipeline = new AWS.CodePipeline(); // Retrieve the Job ID from the Lambda action var jobId = event["CodePipeline.job"].id; // Retrieve the value of UserParameters from the Lambda action configuration in AWS CodePipeline, in this case a URL which will be // health checked by this function. var url = event["CodePipeline.job"].data.actionConfiguration.configuration.UserParameters; // Notify AWS CodePipeline of a successful job var putJobSuccess = function(message) { var params = { jobId: jobId };
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-4
var putJobSuccess = function(message) { var params = { jobId: jobId }; codepipeline.putJobSuccessResult(params, function(err, data) { if(err) { context.fail(err); } else { context.succeed(message); } }); }; // Notify AWS CodePipeline of a failed job var putJobFailure = function(message) { var params = { jobId: jobId, failureDetails: { message: JSON.stringify(message), type: 'JobFailed', externalExecutionId: context.awsRequestId } }; codepipeline.putJobFailureResult(params, function(err, data) { context.fail(message); }); }; // Validate the URL passed in UserParameters if(!url || url.indexOf('http://') === -1) { putJobFailure('The UserParameters field must contain a valid URL address to test, including http:// or https://'); return; }
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-5
return; } // Helper function to make a HTTP GET request to the page. // The helper will test the response and succeed or fail the job accordingly var getPage = function(url, callback) { var pageObject = { body: '', statusCode: 0, contains: function(search) { return this.body.indexOf(search) > -1; } }; http.get(url, function(response) { pageObject.body = ''; pageObject.statusCode = response.statusCode; response.on('data', function (chunk) { pageObject.body += chunk; }); response.on('end', function () { callback(pageObject); }); response.resume(); }).on('error', function(error) { // Fail the job if our request failed putJobFailure(error); }); }; getPage(url, function(returnedPage) { try { // Check if the HTTP response has a 200 status assert(returnedPage.statusCode === 200); // Check if the page contains the text "Congratulations"
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
fbd958851811-6
assert(returnedPage.statusCode === 200); // Check if the page contains the text "Congratulations" // You can change this to check for different text, or add other tests as required assert(returnedPage.contains('Congratulations')); // Succeed the job putJobSuccess("Tests passed."); } catch (ex) { // If any of the assertions failed then fail the job putJobFailure(ex); } }); }; ``` 1. Leave **Handler** at the default value, and leave **Role** at the default, **CodePipelineLambdaExecRole**\. 1. In **Basic settings**, for **Timeout**, enter **20** seconds\. 1. Choose **Save**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
6a275c5d7954-0
In this step, you add a new stage to your pipeline, and then add a Lambda action that calls your function to that stage\. **To add a stage** 1. Sign in to the AWS Management Console and open the CodePipeline console at [http://console\.aws\.amazon\.com/codesuite/codepipeline/home](http://console.aws.amazon.com/codesuite/codepipeline/home)\. 1. On the **Welcome** page, choose the pipeline you created\. 1. On the pipeline view page, choose **Edit**\. 1. On the **Edit** page, choose **\+ Add stage** to add a stage after the deployment stage with the CodeDeploy action\. Enter a name for the stage \(for example, **LambdaStage**\), and choose **Add stage**\. **Note** You can also choose to add your Lambda action to an existing stage\. For demonstration purposes, we are adding the Lambda function as the only action in a stage to allow you to easily view its progress as artifacts progress through a pipeline\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
6a275c5d7954-1
1. Choose **\+ Add action group**\. In **Edit action**, in **Action name**, enter a name for your Lambda action \(for example, **MyLambdaAction**\)\. In **Provider**, choose **AWS Lambda**\. In **Function name**, choose or enter the name of your Lambda function \(for example, **MyLambdaFunctionForAWSCodePipeline**\)\. In **User parameters**, specify the IP address for the Amazon EC2 instance you copied earlier \(for example, **http://*192\.0\.2\.4***\), and then choose **Done**\. ![\[The configuration for a Lambda action in the Add action form.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/images/codepipeline-lambda-action-add-pol.png)![\[The configuration for a Lambda action in the Add action form.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/)![\[The configuration for a Lambda action in the Add action form.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/) **Note**
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
6a275c5d7954-2
**Note** This topic uses an IP address, but in a real\-world scenario, you could provide your registered website name instead \(for example, **http://*www\.example\.com***\)\. For more information about event data and handlers in AWS Lambda, see [Programming Model](https://docs.aws.amazon.com/lambda/latest/dg/programming-model-v2.html) in the *AWS Lambda Developer Guide*\. 1. On the **Edit action** page, choose **Save**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
6023f5f5724c-0
To test the function, release the most recent change through the pipeline\. **To use the console to run the most recent version of an artifact through a pipeline** 1. On the pipeline details page, choose **Release change**\. This runs the most recent revision available in each source location specified in a source action through the pipeline\. 1. When the Lambda action is complete, choose the **Details** link to view the log stream for the function in Amazon CloudWatch, including the billed duration of the event\. If the function failed, the CloudWatch log provides information about the cause\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
3fb8609c7c0f-0
Now that you've successfully created a Lambda function and added it as an action in a pipeline, you can try the following: + Add more Lambda actions to your stage to check other webpages\. + Modify the Lambda function to check for a different text string\. + [Explore Lambda functions](https://docs.aws.amazon.com/lambda/latest/dg/use-cases.html) and create and add your own Lambda functions to pipelines\. ![\[An AWS Lambda action running through a pipeline.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/images/codepipeline-lambda-action-add-2-inprog-pol.png)![\[An AWS Lambda action running through a pipeline.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/)![\[An AWS Lambda action running through a pipeline.\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
3fb8609c7c0f-1
After you have finished experimenting with the Lambda function, consider removing it from your pipeline, deleting it from AWS Lambda, and deleting the role from IAM to avoid possible charges\. For more information, see [Edit a pipeline in CodePipeline](pipelines-edit.md), [Delete a pipeline in CodePipeline](pipelines-delete.md), and [Deleting Roles or Instance Profiles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
8e0b00bda0e4-0
The following example shows a sample JSON event sent to Lambda by CodePipeline\. The structure of this event is similar to the response to the `[GetJobDetails API](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_GetJobDetails.html)`, but without the `actionTypeId` and `pipelineContext` data types\. Two action configuration details, `FunctionName` and `UserParameters`, are included in both the JSON event and the response to the `GetJobDetails` API\. The values in *red italic text* are examples or explanations, not real values\. ``` { "CodePipeline.job": { "id": "11111111-abcd-1111-abcd-111111abcdef", "accountId": "111111111111", "data": { "actionConfiguration": { "configuration": { "FunctionName": "MyLambdaFunctionForAWSCodePipeline", "UserParameters": "some-input-such-as-a-URL" } }, "inputArtifacts": [ { "location": { "s3Location": {
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
8e0b00bda0e4-1
"inputArtifacts": [ { "location": { "s3Location": { "bucketName": "the name of the bucket configured as the pipeline artifact store in Amazon S3, for example codepipeline-us-east-2-1234567890", "objectKey": "the name of the application, for example CodePipelineDemoApplication.zip" }, "type": "S3" }, "revision": null, "name": "ArtifactName" } ], "outputArtifacts": [], "artifactCredentials": { "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "sessionToken": "MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w 0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZ WF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIw
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
8e0b00bda0e4-2
EAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5 jb20wHhcNMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBh MCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBb WF6b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMx HzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wgZ8wDQYJKoZIhvcNAQE BBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ21uUSfwfEvySWtC2XADZ4nB+BLYgVI k60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9TrDHudUZg3qX4waLG5M43q7Wgc/MbQ ITxOUSQv7c7ugFFDzQGBzZswY6786m86gpEIbb3OhjZnzcvQAaRHhdlQWIMm2nr
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
8e0b00bda0e4-3
AgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4nUhVVxYUntneD9+h8Mg9q6q+auN KyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0FkbFFBjvSfpJIlJ00zbhNYS5f6Guo EDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTbNYiytVbZPQUQ5Yaxu2jXnimvw 3rrszlaEXAMPLE=", "accessKeyId": "AKIAIOSFODNN7EXAMPLE" }, "continuationToken": "A continuation token if continuing job", "encryptionKey": { "id": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "type": "KMS" } } } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
225083793a10-0
The following sample Lambda functions demonstrate additional functionality you can use for your pipelines in CodePipeline\. To use these functions, you might have to modify the policy for the Lambda execution role, as noted in the introduction for each sample\. **Topics** + [Sample Python function that uses an AWS CloudFormation template](#actions-invoke-lambda-function-samples-python-cloudformation)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-0
The following sample shows a function that creates or updates a stack based on a supplied AWS CloudFormation template\. The template creates an Amazon S3 bucket\. It is for demonstration purposes only, to minimize costs\. Ideally, you should delete the stack before you upload anything to the bucket\. If you upload files to the bucket, you cannot delete the bucket when you delete the stack\. You must manually delete everything in the bucket before you can delete the bucket itself\. This Python sample assumes you have a pipeline that uses an Amazon S3 bucket as a source action, or that you have access to a versioned Amazon S3 bucket you can use with the pipeline\. You create the AWS CloudFormation template, compress it, and upload it to that bucket as a \.zip file\. You must then add a source action to your pipeline that retrieves this \.zip file from the bucket\. **Note** When Amazon S3 is the source provider for your pipeline, you may zip your source file or files into a single \.zip and upload the \.zip to your source bucket\. You may also upload a single unzipped file; however, downstream actions that expect a \.zip file will fail\. This sample demonstrates: + The use of JSON\-encoded user parameters to pass multiple configuration values to the function \(`get_user_params`\)\. + The interaction with \.zip artifacts in an artifact bucket \(`get_template`\)\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-1
+ The interaction with \.zip artifacts in an artifact bucket \(`get_template`\)\. + The use of a continuation token to monitor a long\-running asynchronous process \(`continue_job_later`\)\. This allows the action to continue and the function to succeed even if it exceeds a fifteen\-minute runtime \(a limit in Lambda\)\. To use this sample Lambda function, the policy for the Lambda execution role must have `Allow` permissions in AWS CloudFormation, Amazon S3, and CodePipeline, as shown in this sample policy: ``` { "Version": "2012-10-17", "Statement": [ { "Action": [ "logs:*" ], "Effect": "Allow", "Resource": "arn:aws:logs:*:*:*" }, { "Action": [ "codepipeline:PutJobSuccessResult", "codepipeline:PutJobFailureResult" ], "Effect": "Allow", "Resource": "*" }, { "Action": [ "cloudformation:DescribeStacks", "cloudformation:CreateStack", "cloudformation:UpdateStack" ],
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-2
"cloudformation:CreateStack", "cloudformation:UpdateStack" ], "Effect": "Allow", "Resource": "*" }, { "Action": [ "s3:*" ], "Effect": "Allow", "Resource": "*" } ] } ``` To create the AWS CloudFormation template, open any plain\-text editor and copy and paste the following code: ``` { "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AWS CloudFormation template which creates an S3 bucket", "Resources" : { "MySampleBucket" : { "Type" : "AWS::S3::Bucket", "Properties" : { } } }, "Outputs" : { "BucketName" : { "Value" : { "Ref" : "MySampleBucket" }, "Description" : "The name of the S3 bucket" } } } ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-3
"Description" : "The name of the S3 bucket" } } } ``` Save this as a JSON file with the name **template\.json** in a directory named **template\-package**\. Create a compressed \(\.zip\) file of this directory and file named **template\-package\.zip**, and upload the compressed file to a versioned Amazon S3 bucket\. If you already have a bucket configured for your pipeline, you can use it\. Next, edit your pipeline to add a source action that retrieves the \.zip file\. Name the output for this action *MyTemplate*\. For more information, see [Edit a pipeline in CodePipeline](pipelines-edit.md)\. **Note** The sample Lambda function expects these file names and compressed structure\. However, you can substitute your own AWS CloudFormation template for this sample\. If you use your own template, make sure you modify the policy for the Lambda execution role to allow any additional functionality required by your AWS CloudFormation template\. **To add the following code as a function in Lambda** 1. Open the Lambda console and choose **Create function**\. 1. On the **Create function** page, choose **Author from scratch**\. In **Function name**, enter a name for your Lambda function\. 1. In **Runtime**, choose **Python 2\.7**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-4
1. In **Runtime**, choose **Python 2\.7**\. 1. Under **Choose or create an execution role**, select **Use an existing role**\. In **Existing role**, choose your role, and then choose **Create function**\. The detail page for your created function opens\. 1. Copy the following code into the **Function code** box: ``` from __future__ import print_function from boto3.session import Session import json import urllib import boto3 import zipfile import tempfile import botocore import traceback print('Loading function') cf = boto3.client('cloudformation') code_pipeline = boto3.client('codepipeline') def find_artifact(artifacts, name): """Finds the artifact 'name' among the 'artifacts' Args: artifacts: The list of artifacts available to the function name: The artifact we wish to use Returns: The artifact dictionary found Raises: Exception: If no matching artifact is found """ for artifact in artifacts: if artifact['name'] == name: return artifact
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-5
""" for artifact in artifacts: if artifact['name'] == name: return artifact raise Exception('Input artifact named "{0}" not found in event'.format(name)) def get_template(s3, artifact, file_in_zip): """Gets the template artifact Downloads the artifact from the S3 artifact store to a temporary file then extracts the zip and returns the file containing the CloudFormation template. Args: artifact: The artifact to download file_in_zip: The path to the file within the zip containing the template Returns: The CloudFormation template as a string Raises: Exception: Any exception thrown while downloading the artifact or unzipping it """ tmp_file = tempfile.NamedTemporaryFile() bucket = artifact['location']['s3Location']['bucketName'] key = artifact['location']['s3Location']['objectKey'] with tempfile.NamedTemporaryFile() as tmp_file: s3.download_file(bucket, key, tmp_file.name) with zipfile.ZipFile(tmp_file.name, 'r') as zip: return zip.read(file_in_zip) def update_stack(stack, template):
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-6
return zip.read(file_in_zip) def update_stack(stack, template): """Start a CloudFormation stack update Args: stack: The stack to update template: The template to apply Returns: True if an update was started, false if there were no changes to the template since the last update. Raises: Exception: Any exception besides "No updates are to be performed." """ try: cf.update_stack(StackName=stack, TemplateBody=template) return True except botocore.exceptions.ClientError as e: if e.response['Error']['Message'] == 'No updates are to be performed.': return False else: raise Exception('Error updating CloudFormation stack "{0}"'.format(stack), e) def stack_exists(stack): """Check if a stack exists or not Args: stack: The stack to check Returns: True or False depending on whether the stack exists Raises: Any exceptions raised .describe_stacks() besides that the stack doesn't exist. """ try: cf.describe_stacks(StackName=stack) return True except botocore.exceptions.ClientError as e:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-7
cf.describe_stacks(StackName=stack) return True except botocore.exceptions.ClientError as e: if "does not exist" in e.response['Error']['Message']: return False else: raise e def create_stack(stack, template): """Starts a new CloudFormation stack creation Args: stack: The stack to be created template: The template for the stack to be created with Throws: Exception: Any exception thrown by .create_stack() """ cf.create_stack(StackName=stack, TemplateBody=template) def get_stack_status(stack): """Get the status of an existing CloudFormation stack Args: stack: The name of the stack to check Returns: The CloudFormation status string of the stack such as CREATE_COMPLETE Raises: Exception: Any exception thrown by .describe_stacks() """ stack_description = cf.describe_stacks(StackName=stack) return stack_description['Stacks'][0]['StackStatus'] def put_job_success(job, message): """Notify CodePipeline of a successful job Args: job: The CodePipeline job ID
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-8
"""Notify CodePipeline of a successful job Args: job: The CodePipeline job ID message: A message to be logged relating to the job status Raises: Exception: Any exception thrown by .put_job_success_result() """ print('Putting job success') print(message) code_pipeline.put_job_success_result(jobId=job) def put_job_failure(job, message): """Notify CodePipeline of a failed job Args: job: The CodePipeline job ID message: A message to be logged relating to the job status Raises: Exception: Any exception thrown by .put_job_failure_result() """ print('Putting job failure') print(message) code_pipeline.put_job_failure_result(jobId=job, failureDetails={'message': message, 'type': 'JobFailed'}) def continue_job_later(job, message): """Notify CodePipeline of a continuing job This will cause CodePipeline to invoke the function again with the supplied continuation token. Args: job: The JobID message: A message to be logged relating to the job status continuation_token: The continuation token Raises:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
0e55129df2b2-9
job: The JobID message: A message to be logged relating to the job status continuation_token: The continuation token Raises: Exception: Any exception thrown by .put_job_success_result() """
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
03b41c5bd598-0
continuation_token = json.dumps({'previous_job_id': job}) print('Putting job continuation') print(message) code_pipeline.put_job_success_result(jobId=job, continuationToken=continuation_token) def start_update_or_create(job_id, stack, template): """Starts the stack update or create process If the stack exists then update, otherwise create. Args: job_id: The ID of the CodePipeline job stack: The stack to create or update template: The template to create/update the stack with """ if stack_exists(stack): status = get_stack_status(stack) if status not in ['CREATE_COMPLETE', 'ROLLBACK_COMPLETE', 'UPDATE_COMPLETE']:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
7b93cf661d69-0
put_job_failure(job_id, 'Stack cannot be updated when status is: ' + status) return were_updates = update_stack(stack, template) if were_updates:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
6cc3eb2a809a-0
continue_job_later(job_id, 'Stack update started') else:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
d5b47195c1e8-0
put_job_success(job_id, 'There were no stack updates') else:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
4577e6f18b45-0
create_stack(stack, template)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
8402d3de9699-0
continue_job_later(job_id, 'Stack create started') def check_stack_update_status(job_id, stack): """Monitor an already-running CloudFormation update/create Succeeds, fails or continues the job depending on the stack status. Args: job_id: The CodePipeline job ID stack: The stack to monitor """ status = get_stack_status(stack) if status in ['UPDATE_COMPLETE', 'CREATE_COMPLETE']:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
01d009affaa3-0
put_job_success(job_id, 'Stack update complete') elif status in ['UPDATE_IN_PROGRESS', 'UPDATE_ROLLBACK_IN_PROGRESS', 'UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS', 'CREATE_IN_PROGRESS', 'ROLLBACK_IN_PROGRESS']:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
9c4408a5b4c4-0
continue_job_later(job_id, 'Stack update still in progress') else:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
9f163f5cf4fe-0
put_job_failure(job_id, 'Update failed: ' + status) def get_user_params(job_data): """Decodes the JSON user parameters and validates the required properties. Args: job_data: The job data structure containing the UserParameters string which should be a valid JSON structure Returns: The JSON parameters decoded as a dictionary. Raises: Exception: The JSON can't be decoded or a property is missing. """ try:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
b89cc298584f-0
user_parameters = job_data['actionConfiguration']['configuration']['UserParameters'] decoded_parameters = json.loads(user_parameters) except Exception as e:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
4056de8a48e9-0
raise Exception('UserParameters could not be decoded as JSON') if 'stack' not in decoded_parameters:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
e3b5890ee619-0
raise Exception('Your UserParameters JSON must include the stack name') if 'artifact' not in decoded_parameters: raise Exception('Your UserParameters JSON must include the artifact name') if 'file' not in decoded_parameters: raise Exception('Your UserParameters JSON must include the template file name') return decoded_parameters def setup_s3_client(job_data): """Creates an S3 client Uses the credentials passed in the event by CodePipeline. These credentials can be used to access the artifact bucket. Args: job_data: The job data structure Returns: An S3 client with the appropriate credentials """ key_id = job_data['artifactCredentials']['accessKeyId'] key_secret = job_data['artifactCredentials']['secretAccessKey'] session_token = job_data['artifactCredentials']['sessionToken'] session = Session(aws_access_key_id=key_id, aws_secret_access_key=key_secret, aws_session_token=session_token) return session.client('s3', config=botocore.client.Config(signature_version='s3v4')) def lambda_handler(event, context):
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
e3b5890ee619-1
def lambda_handler(event, context): """The Lambda function handler If a continuing job then checks the CloudFormation stack status and updates the job accordingly. If a new job then kick of an update or creation of the target CloudFormation stack. Args: event: The event passed by Lambda context: The context passed by Lambda """ try:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
581cd3978164-0
job_id = event['CodePipeline.job']['id']
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
d194c9042a51-0
job_data = event['CodePipeline.job']['data']
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
2e6f15b8f03d-0
params = get_user_params(job_data)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
7212ab5b76cd-0
artifacts = job_data['inputArtifacts'] stack = params['stack'] artifact = params['artifact'] template_file = params['file'] if 'continuationToken' in job_data:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
7e93dcde4595-0
check_stack_update_status(job_id, stack) else:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
72106d203518-0
artifact_data = find_artifact(artifacts, artifact)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
ddac1b8ba40c-0
s3 = setup_s3_client(job_data)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
6920ed45dd47-0
template = get_template(s3, artifact_data, template_file)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
73b07bc33759-0
start_update_or_create(job_id, stack, template) except Exception as e:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
db864308fc2b-0
print('Function failed due to exception.') print(e) traceback.print_exc() put_job_failure(job_id, 'Function exception: ' + str(e)) print('Function complete.') return "Complete." ``` 1. Leave **Handler** at the default value, and leave **Role** at the name you selected or created earlier, **CodePipelineLambdaExecRole**\. 1. In **Basic settings**, for **Timeout**, replace the default of 3 seconds with **20**\. 1. Choose **Save**\. 1. From the CodePipeline console, edit the pipeline to add the function as an action in a stage in your pipeline\. Choose **Edit** for the pipeline stage you want to change, and choose **Add action group**\. On the **Edit action** page, in **Action name**, enter a name for your action\. In **Action provider**, choose **AWS Lambda**\. Under **Input artifacts**, choose `MyTemplate`\. In **UserParameters**, you must provide a JSON string with three parameters: + Stack name + AWS CloudFormation template name and path to the file + Input artifact
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
db864308fc2b-1
+ Stack name + AWS CloudFormation template name and path to the file + Input artifact Use curly brackets \(\{ \}\) and separate the parameters with commas\. For example, to create a stack named *MyTestStack*, for a pipeline with the input artifact *MyTemplate*, in **UserParameters**, enter: \{"stack":"*MyTestStack*","file":"template\-package/template\.json","artifact":"*MyTemplate*"\}\. **Note** Even though you have specified the input artifact in **UserParameters**, you must also specify this input artifact for the action in **Input artifacts**\. 1. Save your changes to the pipeline, and then manually release a change to test the action and Lambda function\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/actions-invoke-lambda-function.md
02fd74c6d40f-0
This walkthrough shows you how to use the AWS CloudFormation console to create infrastructure that includes a pipeline connected to a GitHub source repository\. In this tutorial, you use the provided sample template file to create your resource stack, which includes your artifact store, pipeline, and change\-detection resource \(your webhook\)\. After you create your resource stack in AWS CloudFormation, you can view your pipeline in the AWS CodePipeline console\. The pipeline is a two\-stage pipeline with a GitHub source stage and a CodeDeploy deployment stage\. We strongly recommend that you use AWS Secrets Manager to store your credentials\. If you use Secrets Manager, you must have already configured and stored your secret parameters in Secrets Manager\. This example uses dynamic references to AWS Secrets Manager for the GitHub credentials for your webhook\. For more information, see [ Using Dynamic References to Specify Template Values](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager)\. **Important** When passing secret parameters, do not enter the value directly into the template\. The value is rendered as plaintext and is therefore readable\. For security reasons, do not use plaintext in your AWS CloudFormation template to store your credentials\. **Prerequisites:** You must have created the following resources to use with the AWS CloudFormation sample template:
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/tutorials-cloudformation-github.md
02fd74c6d40f-1
**Prerequisites:** You must have created the following resources to use with the AWS CloudFormation sample template: + A CodeDeploy application and deployment group\. You can use the CodeDeploy resources you created in [Tutorial: Create a simple pipeline \(CodeCommit repository\)](tutorials-simple-codecommit.md)\. + Choose one of these links to download the sample AWS CloudFormation template file for creating a pipeline: [YAML](samples/codepipeline-github-events-yaml.zip) \| [JSON](samples/codepipeline-github-events-json.zip) Unzip the file and place it on your local computer\. + The sample templates in the bullet above are configured to use a GitHub secret token with this dynamic reference to the stored token in AWS Secrets Manager: `{{resolve:secretsmanager:MyGitHubSecret:SecretString:token}}`\. You must create a GitHub token and store it in Secrets Manager in order to use the dynamic reference in the template for your `OAuthToken` and `SecretToken` fields\. + Download the [SampleApp\_Linux\.zip](samples/SampleApp_Linux.zip)\. + The GitHub repository and branch you want to use for your source\. + A personal access key for your GitHub repository\. This is used to provide an OAuth token for connection to your repository\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/tutorials-cloudformation-github.md
02fd74c6d40f-2
+ A personal access key for your GitHub repository\. This is used to provide an OAuth token for connection to your repository\. 1. Unzip the files from [SampleApp\_Linux\.zip](samples/SampleApp_Linux.zip) and upload the files to your GitHub repository\. You must upload the unzipped files to the root directory of your repository\. 1. Open the AWS CloudFormation console and choose **Create Stack**\. 1. In **Choose a template**, choose **Upload a template to Amazon S3**\. Choose **Browse**, and then select the template file from your local computer\. Choose **Next**\. 1. In **Stack name**, enter a name for your pipeline\. Parameters specified by the sample template are displayed\. Enter the following parameters: 1. In **ApplicationName**, enter the name of your CodeDeploy application\. 1. In **BetaFleet**, enter the name of your CodeDeploy deployment group\. 1. In **BranchName**, enter the repository branch you want to use\. 1. In **GitHubOAuthToken**, enter the personal access key for your GitHub repository\. 1. In **GitHubOwner**, enter the GitHub user name for the owner of the repository\. 1. In **GitHubSecret**, enter the secret you want to use for the webhook AWS CloudFormation creates\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/tutorials-cloudformation-github.md
02fd74c6d40f-3
1. In **GitHubSecret**, enter the secret you want to use for the webhook AWS CloudFormation creates\. 1. In **RepositoryName**, enter the name of your GitHub source repository\. ![\[\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/images/create-stack-github-pipeline.png) 1. Choose **Next**\. Accept the defaults on the following page, and then choose **Next**\. 1. In **Capabilities**, select **I acknowledge that AWS CloudFormation might create IAM resources**, and then choose **Create**\. 1. After your stack creation is complete, view the event list to check for any errors\. 1. Sign in to the AWS Management Console and open the CodePipeline console at [https://console\.aws\.amazon\.com/codepipeline/](https://console.aws.amazon.com/codepipeline/)\. Under **Pipelines**, choose your pipeline, and then choose **View**\. The diagram shows your pipeline source and deployment stages\. 1. In your source repository, commit and push a change\. Your change\-detection resources pick up the change and your pipeline starts\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/tutorials-cloudformation-github.md
272f3af79a4d-0
To define an automated release process in AWS CodePipeline, you create a pipeline, which is a workflow construct that describes how software changes go through a release process\. A pipeline is composed of stages and actions that you configure\. **Note** When you add Build, Deploy, Test, or Invoke stages, in addition to the default options provided with CodePipeline, you can choose custom actions that you have already created for use with your pipelines\. Custom actions can be used for tasks such as running an internally developed build process or a test suite\. Version identifiers are included to help you distinguish among different versions of a custom action in the provider lists\. For more information, see [Create and add a custom action in CodePipeline](actions-create-custom-action.md)\. Before you can create a pipeline, you must first complete the steps in [Getting started with CodePipeline](getting-started-codepipeline.md)\. For more information about pipelines, see [CodePipeline concepts](concepts.md), [CodePipeline tutorials](tutorials.md), and, if you want to use the AWS CLI to create a pipeline, [CodePipeline pipeline structure reference](reference-pipeline-structure.md)\. To view a list of pipelines, see [View pipeline details and history in CodePipeline](pipelines-view.md)\. **Topics** + [Start a pipeline execution](pipelines-about-starting.md) + [Stop a pipeline execution](pipelines-stop.md) + [Create a pipeline](pipelines-create.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/pipelines.md
272f3af79a4d-1
+ [Stop a pipeline execution](pipelines-stop.md) + [Create a pipeline](pipelines-create.md) + [Edit a pipeline](pipelines-edit.md) + [View pipeline details and history](pipelines-view.md) + [Delete a pipeline](pipelines-delete.md) + [Create a pipeline that uses resources from another account](pipelines-create-cross-account.md) + [Edit a pipeline for push events](update-change-detection.md) + [Create the CodePipeline service role](pipelines-create-service-role.md) + [Tag a pipeline](pipelines-tag.md) + [Create a connection to Bitbucket](connections-pipelines.md) + [Create a notification rule](notification-rule-create.md)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/pipelines.md
db04dce1c2d4-0
When a pipeline includes an approval action, the pipeline execution stops at the point where the action has been added\. The pipeline won't resume unless someone manually approves the action\. If an approver rejects the action, or if no approval response is received within seven days of the pipeline stopping for the approval action, the pipeline status becomes "Failed\." If the person who added the approval action to the pipeline configured notifications, you might receive an email that looks similar to the following: ![\[A sample notification email for a manual approval request\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/images/approvals-email-example.png)![\[A sample notification email for a manual approval request\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/)![\[A sample notification email for a manual approval request\]](http://docs.aws.amazon.com/codepipeline/latest/userguide/)
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals-approve-or-reject.md
85fd7e6276bc-0
If you receive a notification that includes a direct link to an approval action, choose the **Approve or reject** link, sign in to the console, and then continue with step 7 here\. Otherwise, follow all of these steps\. 1. Open the CodePipeline console at [https://console\.aws\.amazon\.com/codepipeline/](https://console.aws.amazon.com/codepipeline/)\. 1. On the **All Pipelines** page, choose the name of the pipeline\. 1. Locate the stage with the approval action\. 1. Hover over the information icon to view the comments and URL, if any\. The message also displays the URL of content for you to review, if one was included\. 1. If a URL was provided, choose the **Manual approval** link in the action to open the target webpage, and then review the content\. 1. Return to the pipeline details view, and then choose **Review**\. 1. In the **Approve or reject the revision** window, enter review comments, such as why you are approving or rejecting the action, and then choose **Approve** or **Reject**\.
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals-approve-or-reject.md
9db877587a5c-0
To use the CLI to respond to an approval action, you must first use the get\-pipeline\-state command to retrieve the token associated with latest execution of the approval action\. 1. At a terminal \(Linux, macOS, or Unix\) or command prompt \(Windows\), run the [get\-pipeline\-state](https://docs.aws.amazon.com/cli/latest/reference/codepipeline/get-pipeline-state.html) command on the pipeline that contains the approval action\. For example, for a pipeline named *MyFirstPipeline*, enter the following: ``` aws codepipeline get-pipeline-state --name MyFirstPipeline ``` 1. In the response to the command, locate the `token` value, which appears in `latestExecution` in the `actionStates` section for the approval action, as shown here: ``` { "created": 1467929497.204, "pipelineName": "MyFirstPipeline", "pipelineVersion": 1, "stageStates": [ { "actionStates": [ { "actionName": "MyApprovalAction", "currentRevision": { "created": 1467929497.204, "revisionChangeId": "CEM7d6Tp7zfelUSLCPPwo234xEXAMPLE",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals-approve-or-reject.md
9db877587a5c-1
"revisionChangeId": "CEM7d6Tp7zfelUSLCPPwo234xEXAMPLE", "revisionId": "HYGp7zmwbCPPwo23xCMdTeqIlEXAMPLE" }, "latestExecution": { "lastUpdatedBy": "arn:aws:iam::123456789012:user/Bob", "summary": "The new design needs to be reviewed before release.", "token": "1a2b3c4d-573f-4ea7-a67E-XAMPLETOKEN" } } //More content might appear here } ``` 1. In a plain\-text editor, create a file where you add the following, in JSON format: + The name of the pipeline that contains the approval action\. + The name of the stage that contains the approval action\. + The name of the approval action\. + The token value you collected in the previous step\. + Your response to the action \(Approved or Rejected\)\. The response must be capitalized\. + Your summary comments\. For the preceding *MyFirstPipeline* example, your file should look like this: ``` { "pipelineName": "MyFirstPipeline",
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals-approve-or-reject.md
9db877587a5c-2
``` { "pipelineName": "MyFirstPipeline", "stageName": "MyApprovalStage", "actionName": "MyApprovalAction", "token": "1a2b3c4d-573f-4ea7-a67E-XAMPLETOKEN", "result": { "status": "Approved", "summary": "The new design looks good. Ready to release to customers." } } ``` 1. Save the file with a name like **approvalstage\-approved\.json**\. 1. Run the [put\-approval\-result](https://docs.aws.amazon.com/cli/latest/reference/codepipeline/put-approval-result.html) command, specifying the name of the approval JSON file, similar to the following: **Important** Be sure to include `file://` before the file name\. It is required in this command\. ``` aws codepipeline put-approval-result --cli-input-json file://approvalstage-approved.json ```
https://github.com/siagholami/aws-documentation/tree/main/documents/aws-codepipeline-user-guide/doc_source/approvals-approve-or-reject.md