AWS CodeCommit Trigger
This page shows how to write Terraform and CloudFormation for CodeCommit Trigger and write them securely.
aws_codecommit_trigger (Terraform)
The Trigger in CodeCommit can be configured in Terraform with the resource name aws_codecommit_trigger
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_codecommit_trigger" "trigger_1" {
count = var.enable_trigger_1 ? 1 : 0
repository_name = local.repo_name
trigger {
resource "aws_codecommit_trigger" "trigger_1" {
count = var.enable_trigger_1 ? 1 : 0
repository_name = local.repo_name
trigger {
repository_name = local.repo_name
description = var.description
default_branch = var.default_branch
}
resource "aws_codecommit_trigger" "trigger_1" {
resource "aws_codecommit_trigger" "git_trigger" {
repository_name = aws_codecommit_repository.git_repository.repository_name
trigger {
destination_arn = aws_sns_topic.git_notification.arn
events = ["createReference"]
name = "MyFirstDemoTrigger"
resource "aws_codecommit_trigger" "trigger" {
count = length(var.trigger)
repository_name = element(var.repository_name, lookup(var.trigger[count.index], "repository_id"))
dynamic "trigger" {
for_each = lookup(var.trigger[count.index], "trigger")
Parameters
-
configuration_id
optional computed - string -
id
optional computed - string -
repository_name
required - string -
trigger
set block-
branches
optional - list of string -
custom_data
optional - string -
destination_arn
required - string -
events
required - list of string -
name
required - string
-
Explanation in Terraform Registry
Provides a CodeCommit Trigger Resource.
NOTE: Terraform currently can create only one trigger per repository, even if multiple aws_codecommit_trigger resources are defined. Moreover, creating triggers with Terraform will delete all other triggers in the repository (also manually-created triggers).
AWS::CodeCommit::Repository RepositoryTrigger (CloudFormation)
The Repository RepositoryTrigger in CodeCommit can be configured in CloudFormation with the resource name AWS::CodeCommit::Repository RepositoryTrigger
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
Branches
The branches to be included in the trigger configuration. If you specify an empty array, the trigger applies to all branches.
Although no content is required in the array, you must include the array itself.
Required: No
Type: List of String
Update requires: No interruption
CustomData
Any custom data associated with the trigger to be included in the information sent to the target of the trigger.
Required: No
Type: String
Update requires: No interruption
DestinationArn
The ARN of the resource that is the target for a trigger (for example, the ARN of a topic in Amazon SNS).
Required: Yes
Type: String
Update requires: No interruption
Events
The repository events that cause the trigger to run actions in another service, such as sending a notification through Amazon SNS.
The valid value "all" cannot be used with any other values.
Required: Yes
Type: List of String
Update requires: No interruption
Name
The name of the trigger.
Required: Yes
Type: String
Update requires: No interruption
Explanation in CloudFormation Registry
Information about a trigger for a repository. Note If you want to receive notifications about repository events, consider using notifications instead of triggers. For more information, see Configuring notifications for repository events.
Frequently asked questions
What is AWS CodeCommit Trigger?
AWS CodeCommit Trigger is a resource for CodeCommit of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS CodeCommit Trigger?
For Terraform, the AnikG-Org/terraform-aws-service, AnikG-Org/devops-practice and rackspace-infrastructure-automation/aws-terraform-codecommit source code examples are useful. See the Terraform Example section for further details.