首页 > 解决方案 > 在 AWS Code Pipeline 中实现文件转换的最佳方式

问题描述

我正在为 dotnet 4.7.2 项目实施 CodePipeline,其中代码使用 AWS 的代码部署服务部署在 EC2 实例上。

在管道中,代码从 codeCommit Git 存储库中提取,将代码构建成二进制文件,输出工件以 Zip 格式存储在 S3 存储桶中。

在 web.config 中,我们有 appSettings 键值对,这些键值对因域/客户而异。

如何在将 BuildZip 文件部署到 Ec2 实例之前对其应用转换,以便进行与客户端相关的配置。

{
"pipeline": {
    "name": "Module-R13-demo01",
    "roleArn": "arn:aws:iam::58:role/service-role/AWSCodePipelineServiceRole-us-east-2-Module-R13",
    "artifactStore": {
        "type": "S3",
        "location": "codepipeline-us-east-2-55"
    },
    "stages": [
        {
            "name": "Source",
            "actions": [
                {
                    "name": "Source",
                    "actionTypeId": {
                        "category": "Source",
                        "owner": "AWS",
                        "provider": "CodeCommit",
                        "version": "1"
                    },
                    "runOrder": 1,
                    "configuration": {
                        "BranchName": "master",
                        "OutputArtifactFormat": "CODE_ZIP",
                        "PollForSourceChanges": "false",
                        "RepositoryName": "Procurement-Module"
                    },
                    "outputArtifacts": [
                        {
                            "name": "SourceArtifact"
                        }
                    ],
                    "inputArtifacts": [],
                    "region": "us-east-2",
                    "namespace": "SourceVariables"
                }
            ]
        },
        {
            "name": "Build",
            "actions": [
                {
                    "name": "Build",
                    "actionTypeId": {
                        "category": "Build",
                        "owner": "AWS",
                        "provider": "CodeBuild",
                        "version": "1"
                    },
                    "runOrder": 1,
                    "configuration": {
                        "ProjectName": "Procurement-Module-BuildProject"
                    },
                    "outputArtifacts": [
                        {
                            "name": "BuildArtifact"
                        }
                    ],
                    "inputArtifacts": [
                        {
                            "name": "SourceArtifact"
                        }
                    ],
                    "region": "us-east-2",
                    "namespace": "BuildVariables"
                }
            ]
        },
        {
            "name": "Deploy",
            "actions": [
                {
                    "name": "Deploy",
                    "actionTypeId": {
                        "category": "Deploy",
                        "owner": "AWS",
                        "provider": "S3",
                        "version": "1"
                    },
                    "runOrder": 1,
                    "configuration": {
                        "BucketName": "demo4cicdbuildonly",
                        "Extract": "false",
                        "ObjectKey": "Procurement-Module-R13.zip"
                    },
                    "outputArtifacts": [],
                    "inputArtifacts": [
                        {
                            "name": "BuildArtifact"
                        }
                    ],
                    "region": "us-east-2",
                    "namespace": "DeployVariables"
                }
            ]
        }
    ],
    "version": 1
}

}

标签: amazon-s3aws-lambdaaws-codepipelineaws-code-deploy

解决方案


推荐阅读