Reputation: 691
I want to tag a commit with dynamic tag, for example git tag deploy-$(date +"%Y-%m-%d_%H-%M-%S")
, and then trigger codepipeline from cloudwatch. The problem is if I use following cloudwatch event pattern:
{
"source": [
"aws.codecommit"
],
"detail-type": [
"CodeCommit Repository State Change"
],
"resources": [
"arn:aws:codecommit:region:XXX:someName"
],
"detail": {
"event": [
"referenceCreated",
"referenceUpdated"
],
"repositoryName": [
"someName"
],
"referenceType": [
"tag"
],
"referenceName": [
"deploy"
]
}
}
it will be triggered only on specific tag - "deploy". Is there a way to say any tag that starts with(contains) deploy keyword?
Upvotes: 4
Views: 2314
Reputation: 238687
I was looking at the Content-based Filtering with Event Patterns docs and its Prefix Matching. The example given in the docs is:
{
"time": [ { "prefix": "2017-10-02" } ],
}
Based on the example, the following seems as it could work in your case:
{
"source": [
"aws.codecommit"
],
"detail-type": [
"CodeCommit Repository State Change"
],
"resources": [
"arn:aws:codecommit:region:XXX:someName"
],
"detail": {
"event": [
"referenceCreated",
"referenceUpdated"
],
"repositoryName": [
"someName"
],
"referenceType": [
"tag"
],
"referenceName": [
{ "prefix": "deploy" } ]
]
}
}
Upvotes: 6
Reputation: 8890
You can use a wildcard in the prefix:
{
"source": [
"aws.codecommit"
],
"detail-type": [
"CodeCommit Repository State Change"
],
"detail": {
"referenceType": [
"tag"
],
"referenceName": [
{
"prefix": "deploy-*"
}
]
}
}
Upvotes: 0