-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipelines #17
Pipelines #17
Changes from all commits
d339710
4e78e68
7d77677
8213a74
825058f
aec7361
b3363fc
9b71e6f
71f29f9
b60626f
89f73d2
44fb31a
0fd7355
72d7ab0
ae8598e
5211197
129def3
077d526
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,6 @@ env | |
.cdk.staging | ||
cdk.out | ||
.vscode | ||
local_test.py | ||
local_test.py | ||
|
||
docker-access.key |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@echo off | ||
cdk synth --no-staging > template.yaml | ||
cdk synth DevRenderLambda --no-staging > template.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import typing | ||
|
||
from aws_cdk.core import CfnOutput, Construct, Stage, Environment | ||
from stack.stack import RenderLambdaStack | ||
|
||
class PreprodStage(Stage): | ||
def __init__(self, scope: Construct, id: str) -> None: | ||
super().__init__(scope, id) | ||
|
||
service = RenderLambdaStack(self, 'RenderStack') | ||
|
||
class ProdStage(Stage): | ||
def __init__(self, scope: Construct, id: str) -> None: | ||
super().__init__(scope, id) | ||
|
||
service = RenderLambdaStack(self, 'RenderLambdaStack') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
from aws_cdk import core as cdk | ||
from aws_cdk import pipelines | ||
from aws_cdk import aws_codepipeline_actions as codepipeline_actions | ||
from aws_cdk import aws_codepipeline as codepipeline | ||
|
||
from stack.pipeline_stages import PreprodStage, ProdStage | ||
# used this as reference | ||
# https://aws.amazon.com/blogs/developer/cdk-pipelines-continuous-delivery-for-aws-cdk-applications/ | ||
class RenderLambdaPipeline(cdk.Stack): | ||
|
||
def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: | ||
super().__init__(scope, construct_id, **kwargs) | ||
|
||
|
||
|
||
source_artifact = codepipeline.Artifact() | ||
cloudAssemblyArtifact = codepipeline.Artifact() | ||
|
||
pipeline = pipelines.CdkPipeline(self, 'RenderLambdaPipeline', | ||
# pipeline name and assembly | ||
pipeline_name='RenderLambdaPipeline', | ||
cloud_assembly_artifact=cloudAssemblyArtifact, | ||
|
||
# where the code comes from | ||
source_action=codepipeline_actions.GitHubSourceAction( | ||
action_name='GitHubRenderLambda', | ||
output=source_artifact, | ||
oauth_token=cdk.SecretValue.secrets_manager('github-token', json_field='chand1012'), | ||
owner='pillargg', | ||
repo='render-lambda', | ||
branch='develop' | ||
), | ||
|
||
# synthesises the code | ||
# if this were a typescript project | ||
# it would also compile | ||
synth_action=pipelines.SimpleSynthAction( | ||
install_commands=[ | ||
'npm i -g aws-cdk', | ||
'pip install -r ./requirements.txt' | ||
], | ||
synth_command="cdk synth", | ||
source_artifact=source_artifact, | ||
cloud_assembly_artifact=cloudAssemblyArtifact, | ||
environment={'privileged': True} | ||
# build_commands=['npm run build'] | ||
) | ||
) | ||
|
||
pipeline.add_application_stage(PreprodStage(self, 'PreProd')) | ||
|
||
|
||
class ProdRenderLambdaPipeline(cdk.Stack): | ||
def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None: | ||
super().__init__(scope, construct_id, **kwargs) | ||
|
||
|
||
|
||
source_artifact = codepipeline.Artifact() | ||
cloudAssemblyArtifact = codepipeline.Artifact() | ||
|
||
pipeline = pipelines.CdkPipeline(self, 'RenderLambdaPipeline', | ||
# pipeline name and assembly | ||
pipeline_name='RenderLambdaPipeline', | ||
cloud_assembly_artifact=cloudAssemblyArtifact, | ||
|
||
# where the code comes from | ||
source_action=codepipeline_actions.GitHubSourceAction( | ||
action_name='GitHubRenderLambda', | ||
output=source_artifact, | ||
oauth_token=cdk.SecretValue.secrets_manager('github-token', json_field='chand1012'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this your personal token? You could probably make a company token on GH There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sadly we can't make personal access tokens at a company level, so this will have to do for now. |
||
owner='pillargg', | ||
repo='render-lambda', | ||
branch='master' | ||
), | ||
|
||
# synthesises the code | ||
# if this were a typescript project | ||
# it would also compile | ||
synth_action=pipelines.SimpleSynthAction( | ||
install_commands=[ | ||
'npm i -g aws-cdk', | ||
'pip install -r ./requirements.txt' | ||
], | ||
synth_command="cdk synth", | ||
source_artifact=source_artifact, | ||
cloud_assembly_artifact=cloudAssemblyArtifact, | ||
environment={'privileged': True} | ||
# build_commands=['npm run build'] | ||
) | ||
) | ||
|
||
pipeline.add_application_stage(ProdStage(self, 'Prod')) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - here is another source I saw that was good - https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html