Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何将发布(带有替换变量的包)上载到S3,以便使用codedeploy进行部署_Amazon Web Services_Amazon S3_Octopus Deploy_Aws Code Deploy_Octopus - Fatal编程技术网

Amazon web services 如何将发布(带有替换变量的包)上载到S3,以便使用codedeploy进行部署

Amazon web services 如何将发布(带有替换变量的包)上载到S3,以便使用codedeploy进行部署,amazon-web-services,amazon-s3,octopus-deploy,aws-code-deploy,octopus,Amazon Web Services,Amazon S3,Octopus Deploy,Aws Code Deploy,Octopus,我尝试将AWS代码部署与自动缩放组一起使用。在过去,我使用八达通进行部署,我想迁移到aws 所以,我有一个包含多个步骤的八达通项目。第一步部署一个构建基础设施的cloudformation模板:vpc、子网、部署组、自动缩放组、ELB、S3 Bucket等 其他步骤应替换octopus包的变量,并从第一步检索S3 bucket名称,将其上载到S3 我怎样才能用章鱼做到这一点 谢谢。以下是我是如何做到这一点的: 向流程中添加部署包的步骤。我使用了一个“Jumpbox”来部署,它只需要去某个地方 在

我尝试将AWS代码部署与自动缩放组一起使用。在过去,我使用八达通进行部署,我想迁移到aws

所以,我有一个包含多个步骤的八达通项目。第一步部署一个构建基础设施的cloudformation模板:vpc、子网、部署组、自动缩放组、ELB、S3 Bucket等

其他步骤应替换octopus包的变量,并从第一步检索S3 bucket名称,将其上载到S3

我怎样才能用章鱼做到这一点


谢谢。

以下是我是如何做到这一点的:

  • 向流程中添加部署包的步骤。我使用了一个“Jumpbox”来部署,它只需要去某个地方
  • 在部署包的步骤中,单击

  • 挑选

  • 将此脚本添加为部署脚本。替换变量后,它将上载到AWS S3存储桶

    $sourcePath = $OctopusParameters["Octopus.Action.Package.InstallationDirectoryPath"]
    $destinationPath = $OctopusParameters["Your parameter to the full path where you want the Zip file stored"]
    $destinationPathRootDirectory = $OctopusParameters["Your parameter to the folder"]
    
    Write-Host "Cleaning up previous zip files"
    Remove-Item "$destinationPathRootDirectory\*.zip"
    
    Write-Host "Compressing $sourcePath to $destinationPath"
    Compress-Archive -Path "$sourcePath\*"  -DestinationPath $destinationPath -Force
    
    $params = @{}
    
    #Initialises the S3 Credentials based on the Access Key and Secret Key provided, so that we can invoke the APIs further down
    Set-AWSCredentials -AccessKey $AwsAccessKey -SecretKey $AwsAccessSecret -StoreAs S3Creds
    
    #Initialises the Default AWS Region based on the region provided
    Set-DefaultAWSRegion -Region $AwsRegion
    
    #Gets all relevant files and uploads them
    function Upload($item) 
    {
        #Gets all files and child folders within the given directory
        foreach ($i in Get-ChildItem $item) {
                #Inserts file to AWS
                Write-S3Object -ProfileName S3Creds -BucketName $S3BucketName -Key $($i.Name) -File $i.FullName @params
        }
    }
    
    Upload($destinationPath)
    
  • 添加一个步骤以运行AWS命令行命令,该命令将显示

  • 以下是该步骤中的示例脚本:

        # All these parameters are parameters you set in the variables screen in Octopus Deploy
    
        Write-Host "ApplicationName $AwsApplicationName"
        Write-Host "DeploymentConfigName $AwsCodeDeployConfigName"
        Write-Host "CodeDeployName $AwsCodeDeployGroupName"
        Write-Host "BucketLocation $S3BucketName"
        Write-Host "KeyName $ZipFileName"
    
        # This is the AWS name of the location where you want to put the bucket, such as us-west-1
        Write-Host "BucketLocation $bucketLocation"
    
        $fullyQualifiedBucket = "$S3BucketName-$bucketLocation"
        Write-Host "Fully Qualified Bucket $fullyQualifiedBucket"
    
        $deployment = aws deploy create-deployment --application-name $AwsApplicationName --deployment-config-name $AwsCodeDeployConfigName --deployment-group-name $AwsCodeDeployGroupName --s3-location bucket=$S3BucketName,bundleType=zip,key=$TradingWebSiteZipFileName
        Write-Host "Deployment info $deployment"
    

    它确实在S3存储桶中为每个环境创建了一个唯一的包。所以你必须对此作出解释。这不是世界上最完美的解决方案,如果您反复阅读并找到更好的解决方案,请让我知道

    我不理解您的脚本,例如$TradingWebSiteZipFullPath变量是什么,此路径的目标是什么?很抱歉,从工作示例复制粘贴的危险。这是一个发送进来的参数。您可以在Octopus deploy的变量屏幕中进行设置。对于该特定变量,您需要在服务器上指定两个步骤都可以访问的位置。我的答案类似于C:\CodeDeploy[Project Name][Environment Name][FileName]