首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS Blue Green中的Codepipeline正在工作,但不在服务器中的gihub文件

AWS Blue Green中的Codepipeline正在工作,但不在服务器中的gihub文件
EN

Stack Overflow用户
提问于 2020-06-23 17:56:39
回答 1查看 83关注 0票数 0

Buildspec.yaml

代码语言:javascript
复制
version: 0.2
files:
  - source: /
    destination: /folder-test

phases:
  install:
    commands:
      - apt-get update
      - apt install jq
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - $(aws ecr get-login --region eu-west-1 --no-include-email | sed 's|https://||')
      - IMAGE_TAG=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
  build:
    commands:
      - echo Pulling docker image
      - docker pull 309005414223.dkr.ecr.eu-west-1.amazonaws.com/my-task-webserver-repository:latest
      - echo Running the Docker image...
      - docker run -d=true 309005414223.dkr.ecr.eu-west-1.amazonaws.com/my-task-webserver-repository:latest
  post_build:
    commands:
      - aws ecs describe-task-definition --task-definition my-task-task-definition | jq '.taskDefinition' > taskdef.json
artifacts:
  files:
    - appspec.yaml
    - taskdef.json

Appspec.yml

代码语言:javascript
复制
version: 0.0
Resources:
  - TargetService:
      Type: AWS::ECS::Service
      Properties:
        TaskDefinition: "arn:XXX/YYY"
        LoadBalancerInfo:
          ContainerName: "My-name"
          ContainerPort: "8080"
        NetworkConfiguration:
          AwsvpcConfiguration:
            Subnets: ["subnet-1","subnet-2","subnet-3"]
            SecurityGroups: ["sg-1","sg-2","sg-3"]
            AssignPublicIp: "DISABLED"

Terraform资源(codepipeline)

代码语言:javascript
复制
resource "aws_codepipeline" "codepipeline" {
  name     = "${var.namespace}-stage"
  role_arn = aws_iam_role.role.arn

  artifact_store {
    location = aws_s3_bucket.bucket.bucket
    type     = "S3"
  }

  stage {
    name = "Source"

    action {
      name             = "Source"
      category         = "Source"
      owner            = "ThirdParty"
      provider         = "GitHub"
      version          = "1"
      output_artifacts = ["my-source"]

      configuration = {
        OAuthToken = "UUUU"
        Owner  = var.owner
        Repo   = var.repo
        Branch = var.branch
      }
    }
  }

  stage {
    name = "Build"

    action {
      name             = "Build"
      category         = "Build"
      owner            = "AWS"
      provider         = "CodeBuild"
      version          = "1"
      input_artifacts  = ["my-source"]
      output_artifacts = ["my-build"]

      configuration = {
        ProjectName = my-project
      }
    }
  }


  stage {
    name = "Deploy"

    action {
      name            = "Deploy"
      category        = "Deploy"
      owner           = "AWS"
      provider        = "CodeDeployToECS"
      input_artifacts = ["my-build"]
      version         = "1"

      configuration = {
        ApplicationName     = app_name
        DeploymentGroupName = group_name
        TaskDefinitionTemplateArtifact = "my-build"
        AppSpecTemplateArtifact        = "my-build"
      }
    }
  }
}

Codebuild

代码语言:javascript
复制
resource "aws_codebuild_project" "codebuild" {
  name          = my-project
  description   = "Builds for my-project"
  build_timeout = "15"
  service_role  = aws_iam_role.role.arn

  artifacts {
    type = "CODEPIPELINE"
  }

  environment {
    compute_type    = "BUILD_GENERAL1_SMALL"
    image           = "aws/codebuild/standard:2.0"
    type            = "LINUX_CONTAINER"
    privileged_mode = true

  }

  cache {
    type  = "LOCAL"
    modes = ["LOCAL_DOCKER_LAYER_CACHE", "LOCAL_SOURCE_CACHE"]
  }

  source {
    type = "CODEPIPELINE"
  }

  vpc_config {
          security_group_ids = var.sg_ids
          subnets = ["subnet-1","subnet-2","subnet-3"]
          vpc_id = "vpc-1"
  }
}

在代码管道中,一切都运行得很好。任务被创建,并进行传输重定向。没有日志显示任何问题。就在通过ssh连接到服务器时。文件夹folder-test存在,但除了子文件夹外没有任何内容。文件不在那里。

我尝试在控制台中删除文件夹,并重新部署新的推送,结果相同。

EN

回答 1

Stack Overflow用户

发布于 2020-06-23 18:25:05

根据buildspec.yml的亚马逊网络服务规范,您的文件不符合其规范。

也就是说,在buildspec.yml中没有像您这样的节:

代码语言:javascript
复制
files:
  - source: /
    destination: /folder-test

这可以解释为什么文件/文件夹不是您期望的那样。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62532053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档