Skip to content

Commit

Permalink
Merge pull request #33 from 0x4447/development
Browse files Browse the repository at this point in the history
Conditional Webhook
  • Loading branch information
davidgatti authored Mar 1, 2020
2 parents 8faf3d3 + 8515270 commit 3efdab0
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/*.DS_Store
/CloudFormation.json
27 changes: 27 additions & 0 deletions 02_Metadata/interface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"AWS::CloudFormation::Interface" : {
"ParameterGroups": [
{
"Label" : { "default" : "Basics" },
"Parameters" : [ "CodePipelineArtifactsParam" ]
},
{
"Label" : { "default" : "GitHub" },
"Parameters" : [ "GitHubAccountOwnerParam", "GitHubTokenParam", "StageParam", "AutoDeployParam" ]
},
{
"Label" : { "default" : "Product Configuration" },
"Parameters" : [ "EmailRestingPlace"]
}
],
"ParameterLabels": {
"CodePipelineArtifactsParam": { "default" : "CodePipeline Artifacts" },
"GitHubTokenParam": { "default" : "GitHub Token" },
"GitHubAccountOwnerParam": { "default" : "GitHub Owner" },
"StageParam": { "default" : "Deployment Stage" },
"AutoDeployParam": { "default" : "Autodeployment" },

"EmailRestingPlace": { "default" : "Email Bucket Name" }
}
}
}
8 changes: 8 additions & 0 deletions 03_Parameters/auto_deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"AutoDeployParam": {
"Description": "Don't change this unless you forked your own copy of the repos. And want to have auto deployment for changes in code that you made in your repos. If you set Yes, then the CodePipeline setup will get a Webhook resource, otherwise skipped, since you don't have access to our repos, and can't add a web hook entry in our repos.",
"Type": "String",
"AllowedValues" : ["No", "Yes"],
"Default": "No"
}
}
2 changes: 1 addition & 1 deletion 03_Parameters/code_pipeline_bucket_name.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CodePipelineBucketName": {
"CodePipelineArtifactsParam": {
"Description": "The S3 bucket name where CodePipeline will store the artifacts (this is needed only by CP to work, and pass task results to the next stage) - (This bucket needs to exist already in S3)",
"Type": "String"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ParamGitHubAccountName": {
"Description": "The name of the GitHub account, it is the same names that you find in the URL. Organization or private account.",
"GitHubAccountOwnerParam": {
"Description": "The name of the GitHub account, it is the same names that you find in the URL (Organization or private account).",
"Type": "String",
"Default": "0x4447"
}
Expand Down
4 changes: 2 additions & 2 deletions 03_Parameters/github_token.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"GitHubToken": {
"Description": "You need to create a Personal access tokens (https://github.com/settings/tokens) for CodePipeline to have access to the GitHub repo even if they are public, and the Scope has to have: repo and admin:repo_hook",
"GitHubTokenParam": {
"Description": "You need to create a Personal access tokens (https://github.com/settings/tokens) for CodePipeline to have access to the GitHub repo despite it being public. Find out more here: https://docs.aws.amazon.com/codepipeline/latest/userguide/GitHub-authentication.html",
"NoEcho": true,
"Type": "String"
}
Expand Down
4 changes: 2 additions & 2 deletions 03_Parameters/stage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Stage": {
"Description": "Select what Stage are you deploying.",
"StageParam": {
"Description": "Select what type of environment are you deploying (branch of the repo).",
"Type": "String",
"AllowedValues": ["master", "development"],
"Default": "master",
Expand Down
3 changes: 3 additions & 0 deletions 05_Conditions/github_owner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"GitHubAutodeploymentCondition": { "Fn::Equals": [ {"Ref": "AutoDeployParam"}, "Yes"] }
}
2 changes: 1 addition & 1 deletion 07_Resources/Repos/converter/CodeBuild/Policies/s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": { "Fn::Sub": "arn:aws:s3:::${CodePipelineBucketName}/*"}
"Resource": { "Fn::Sub": "arn:aws:s3:::${CodePipelineArtifactsParam}/*"}
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions 07_Resources/Repos/converter/CodePipeline/_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Properties": {
"Name": "0x4447_s3_email_lambda_converter",
"ArtifactStore": {
"Location": { "Ref": "CodePipelineBucketName" },
"Location": { "Ref": "CodePipelineArtifactsParam" },
"Type": "S3"
},
"RoleArn": { "Fn::GetAtt": ["PipelineConverterRole", "Arn"] },
Expand All @@ -22,11 +22,11 @@
"Version": "1"
},
"Configuration": {
"Owner": { "Ref": "ParamGitHubAccountName" },
"Owner": { "Ref": "GitHubAccountOwnerParam" },
"Repo": "0x4447_product_s3_email_lambda_converter",
"Branch": { "Ref": "Stage" },
"Branch": { "Ref": "StageParam" },
"PollForSourceChanges": false,
"OAuthToken": { "Ref": "GitHubToken" }
"OAuthToken": { "Ref": "GitHubTokenParam" }
},
"OutputArtifacts": [
{
Expand Down
3 changes: 2 additions & 1 deletion 07_Resources/Repos/converter/CodePipeline/webhook.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"PipelineConverterWebhook": {
"Type": "AWS::CodePipeline::Webhook",
"Condition": "GitHubAutodeploymentCondition",
"Properties": {
"Authentication": "GITHUB_HMAC",
"AuthenticationConfiguration": {
"SecretToken": { "Ref": "GitHubToken" }
"SecretToken": { "Ref": "GitHubTokenParam" }
},
"Filters": [
{
Expand Down
2 changes: 1 addition & 1 deletion 07_Resources/Repos/inbound/CodeBuild/Policies/s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": { "Fn::Sub": "arn:aws:s3:::${CodePipelineBucketName}/*"}
"Resource": { "Fn::Sub": "arn:aws:s3:::${CodePipelineArtifactsParam}/*"}
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions 07_Resources/Repos/inbound/CodePipeline/_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Properties": {
"Name": "0x4447_s3_email_lambda_inbound",
"ArtifactStore": {
"Location": { "Ref": "CodePipelineBucketName" },
"Location": { "Ref": "CodePipelineArtifactsParam" },
"Type": "S3"
},
"RoleArn": { "Fn::GetAtt": ["PipelineInboundRole", "Arn"] },
Expand All @@ -22,11 +22,11 @@
"Version": "1"
},
"Configuration": {
"Owner": { "Ref": "ParamGitHubAccountName" },
"Owner": { "Ref": "GitHubAccountOwnerParam" },
"Repo": "0x4447_product_s3_email_lambda_inbound",
"Branch": { "Ref": "Stage" },
"Branch": { "Ref": "StageParam" },
"PollForSourceChanges": false,
"OAuthToken": { "Ref": "GitHubToken" }
"OAuthToken": { "Ref": "GitHubTokenParam" }
},
"OutputArtifacts": [
{
Expand Down
3 changes: 2 additions & 1 deletion 07_Resources/Repos/inbound/CodePipeline/webhook.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"PipelineInboundWebhook": {
"Type": "AWS::CodePipeline::Webhook",
"Condition": "GitHubAutodeploymentCondition",
"Properties": {
"Authentication": "GITHUB_HMAC",
"AuthenticationConfiguration": {
"SecretToken": { "Ref": "GitHubToken" }
"SecretToken": { "Ref": "GitHubTokenParam" }
},
"Filters": [
{
Expand Down
2 changes: 1 addition & 1 deletion 07_Resources/Repos/outbound/CodeBuild/Policies/s3.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": { "Fn::Sub": "arn:aws:s3:::${CodePipelineBucketName}/*"}
"Resource": { "Fn::Sub": "arn:aws:s3:::${CodePipelineArtifactsParam}/*"}
}
]
}
Expand Down
8 changes: 4 additions & 4 deletions 07_Resources/Repos/outbound/CodePipeline/_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Properties": {
"Name": "0x4447_s3_email_lambda_outbound",
"ArtifactStore": {
"Location": { "Ref": "CodePipelineBucketName" },
"Location": { "Ref": "CodePipelineArtifactsParam" },
"Type": "S3"
},
"RoleArn": { "Fn::GetAtt": ["PipelineOutboundRole", "Arn"] },
Expand All @@ -22,11 +22,11 @@
"Version": "1"
},
"Configuration": {
"Owner": { "Ref": "ParamGitHubAccountName" },
"Owner": { "Ref": "GitHubAccountOwnerParam" },
"Repo": "0x4447_product_s3_email_lambda_outbound",
"Branch": { "Ref": "Stage" },
"Branch": { "Ref": "StageParam" },
"PollForSourceChanges": false,
"OAuthToken": { "Ref": "GitHubToken" }
"OAuthToken": { "Ref": "GitHubTokenParam" }
},
"OutputArtifacts": [
{
Expand Down
3 changes: 2 additions & 1 deletion 07_Resources/Repos/outbound/CodePipeline/webhook.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"PipelineOutboundWebhook": {
"Type": "AWS::CodePipeline::Webhook",
"Condition": "GitHubAutodeploymentCondition",
"Properties": {
"Authentication": "GITHUB_HMAC",
"AuthenticationConfiguration": {
"SecretToken": { "Ref": "GitHubToken" }
"SecretToken": { "Ref": "GitHubTokenParam" }
},
"Filters": [
{
Expand Down

0 comments on commit 3efdab0

Please sign in to comment.