예제 #1
0
 def build(self) -> ActionTypeID:
   checkForNoneValues(self)
   return ActionTypeID( Category = str(self._category)
                      , Owner = str(self._owner)
                      , Version = self._version
                      , Provider = self._provider
                      )
def getGitHub(t: Template, outputfiles: str) -> Stages:
    owner = t.add_parameter(
        Parameter("GitHubOwner",
                  Description="GitHub repository owner",
                  Type="String"))
    repo = t.add_parameter(
        Parameter("GitHubRepo",
                  Description="GitHub repository name",
                  Type="String"))
    branch = t.add_parameter(
        Parameter("GitHubBranch",
                  Description="GitHub repository branch",
                  Type="String"))
    token = t.add_parameter(
        Parameter("GitHubToken",
                  Description="GitHub repository OAuth token",
                  Type="String"))
    actionId = ActionTypeID(Category="Source",
                            Owner="ThirdParty",
                            Version="1",
                            Provider="GitHub")
    action = Actions(Name=Sub("${AWS::StackName}-LambdaSource"),
                     ActionTypeId=actionId,
                     Configuration={
                         "Owner": Ref(owner),
                         "Repo": Ref(repo),
                         "Branch": Ref(branch),
                         "OAuthToken": Ref(branch)
                     },
                     OutputArtifacts=[OutputArtifacts(Name=outputfiles)],
                     RunOrder="1")
    return Stages(Name="Source", Actions=[action])
def getDeployResources(t: Template) -> Tuple[ActionTypeID, Role]:
    statements = [
        awacs.aws.Statement(Action=[
            awacs.ec2.Action("*"), awacs.awslambda.GetFunction,
            awacs.awslambda.CreateFunction,
            awacs.awslambda.GetFunctionConfiguration,
            awacs.awslambda.DeleteFunction, awacs.awslambda.UpdateFunctionCode,
            awacs.awslambda.UpdateFunctionConfiguration,
            awacs.awslambda.CreateAlias, awacs.awslambda.DeleteAlias,
            awacs.s3.GetObject
        ],
                            Resource=["*"],
                            Effect=awacs.aws.Allow),
        awacs.aws.Statement(Action=[
            awacs.iam.DeleteRole, awacs.iam.DeleteRolePolicy,
            awacs.iam.GetRole, awacs.iam.PutRolePolicy, awacs.iam.CreateRole,
            awacs.iam.PassRole
        ],
                            Resource=["*"],
                            Effect=awacs.aws.Allow)
    ]
    policy_doc = awacs.aws.Policy(Statement=statements)
    policy = Policy(PolicyDocument=policy_doc,
                    PolicyName="CloudFormationDeployPolicy")
    assume = defaultAssumeRolePolicyDocument("cloudformation.amazonaws.com")
    role = t.add_resource(
        Role("CFDeployRole",
             RoleName=Sub("${AWS::StackName}-CFDeployRole"),
             AssumeRolePolicyDocument=assume,
             Policies=[policy]))
    actionId = ActionTypeID(Category="Deploy",
                            Owner="AWS",
                            Version="1",
                            Provider="CloudFormation")
    return (actionId, role)
def buildCfWithDockerAction(buildRef, inputName: str) -> Action:
    actionId = ActionTypeID(Category="Build",
                            Owner="AWS",
                            Version="1",
                            Provider="CodeBuild")
    return Actions(Name=Sub("${AWS::StackName}-TestCfBuilderAction"),
                   ActionTypeId=actionId,
                   InputArtifacts=[InputArtifacts(Name=inputName)],
                   RunOrder="2",
                   Configuration={"ProjectName": Ref(buildRef)})
def getCodeCommit(t: Template, outputfiles: str) -> Stages:
    repo = t.add_parameter(
        Parameter("CodeCommitRepo",
                  Description="Name of the CodeCommit Repository",
                  Type="String"))
    branch = t.add_parameter(
        Parameter("Branch",
                  Description="Branch triggering the deployment",
                  Type="String"))
    actionId = ActionTypeID(Category="Source",
                            Owner="AWS",
                            Version="1",
                            Provider="CodeCommit")
    action = Actions(Name=Sub("${AWS::StackName}-LambdaSource"),
                     ActionTypeId=actionId,
                     Configuration={
                         "BranchName": Ref(branch),
                         "RepositoryName": Ref(repo)
                     },
                     OutputArtifacts=[OutputArtifacts(Name=outputfiles)],
                     RunOrder="1")
    return Stages(Name="Source", Actions=[action])
예제 #6
0
ArtifactStoreS3Location = t.add_parameter(
    Parameter(
        "ArtifactStoreS3Location",
        Description="This should be an S3 bucket resource or bucket name",
        Type="String"))

pipeline = t.add_resource(
    Pipeline(
        "AppPipeline",
        RoleArn=Ref(CodePipelineServiceRole),
        Stages=[
            Stages(Name="Source",
                   Actions=[
                       Actions(Name="SourceAction",
                               ActionTypeId=ActionTypeID(Category="Source",
                                                         Owner="AWS",
                                                         Version="1",
                                                         Provider="S3"),
                               OutputArtifacts=[
                                   OutputArtifacts(Name="SourceOutput")
                               ],
                               Configuration={
                                   "S3Bucket": {
                                       "Ref": "SourceS3Bucket"
                                   },
                                   "S3ObjectKey": {
                                       "Ref": "SourceS3ObjectKey"
                                   }
                               },
                               RunOrder="1")
                   ]),
            Stages(
예제 #7
0
                           ],
                       }),
         ]))

t.add_resource(
    Pipeline(
        "HelloWorldPipeline",
        RoleArn=GetAtt("PipelineRole", "Arn"),
        ArtifactStore=ArtifactStore(Type="S3", Location=Ref("S3Bucket")),
        Stages=[
            Stages(Name="Source",
                   Actions=[
                       Actions(
                           Name="Source",
                           ActionTypeId=ActionTypeID(Category="Source",
                                                     Owner="ThirdParty",
                                                     Version="1",
                                                     Provider="GitHub"),
                           Configuration={
                               "Owner": "ToBeConfiguredLater",
                               "Repo": "ToBeConfiguredLater",
                               "Branch": "ToBeConfiguredLater",
                               "OAuthToken": "ToBeConfiguredLater"
                           },
                           OutputArtifacts=[OutputArtifacts(Name="App")],
                       )
                   ]),
            Stages(
                Name="Staging",
                Actions=[
                    Actions(
                        Name="Deploy",
예제 #8
0
            "2012-10-17",
            "Statement": [{
                "Action": ["sts:AssumeRole"],
                "Effect": "Allow",
                "Principal": {
                    "Service":
                    ["codepipeline.amazonaws.com", "codebuild.amazonaws.com"]
                }
            }]
        },
    ))

#These are the various states that have to be defined in the pipeline

source_action_id = ActionTypeID(Category='Source',
                                Owner='AWS',
                                Provider='CodeCommit',
                                Version='1')

build_action_id = ActionTypeID(Category='Build',
                               Owner='AWS',
                               Provider='CodeBuild',
                               Version='1')

invoke_action_id = ActionTypeID(Category='Invoke',
                                Owner='AWS',
                                Provider='Lambda',
                                Version='1')

source_action = Actions(
    ActionTypeId=source_action_id,
    ###
예제 #9
0
                           ],
                       }),
         ]))

t.add_resource(
    Pipeline(
        "NetworkPipeline",
        RoleArn=GetAtt("PipelineRole", "Arn"),
        ArtifactStore=ArtifactStore(Type="S3", Location=Ref("S3Bucket")),
        Stages=[
            Stages(Name="Source",
                   Actions=[
                       Actions(
                           Name="Source",
                           ActionTypeId=ActionTypeID(Category="Source",
                                                     Owner="AWS",
                                                     Version="1",
                                                     Provider="CodeCommit"),
                           Configuration={
                               "BranchName": "master",
                               "RepositoryName": Ref("RepoName")
                           },
                           OutputArtifacts=[OutputArtifacts(Name="App")],
                       )
                   ]),
            Stages(
                Name="Build",
                Actions=[
                    Actions(
                        Name="Container",
                        ActionTypeId=ActionTypeID(Category="Build",
                                                  Owner="AWS",