如何使用Jenkins在AWS CDK中安装s3?

嗨,我正在AWS cdk上创建s3存储桶。我正在使用我的企业詹金斯创建管道。下面是我创建s3存储桶的python代码。

app.py

#!/usr/bin/env python3

from aws_cdk import core

from basic_stack import MyStack

app = core.App()
MyStack(app,"hello-cdk-1",env={'region': 'ap-southeast-2'})

app.synth()

在我下面的 basic_stack.sh

import os
from aws_cdk import (
    aws_s3 as s3,core
)

class MyStack(core.Stack):

    def __init__(self,scope: core.Construct,id: str,**kwargs) -> None:
        super().__init__(scope,id,**kwargs)

        environment = os.environ['ENVironMENT']
        bucket_id = 'MyBucketId'
        bucket_name = 'my-bucket-name'
        public_access = s3.BlockPublicaccess(
            block_public_acls = True,block_public_policy = True,ignore_public_acls = True,restrict_public_buckets=True)
        s3.Bucket(self,bucket_id,bucket_name = f'kmartau-{bucket_name}-{environment}',block_public_access = public_access,encryption = s3.BucketEncryption.S3_MANAGED)

下面是我的詹金斯管道。

 withCredentials([[$class: 'AmazonWebServicesCredentialsBinding',credentialsId: "${env.PROJECT_ID}-aws-${env.ENVironMENT}"]]) {
            docker.image("${ECR_HOST}/sharedtools/cdk:latest").inside {
              sh "./scripts/build.sh"
            }

下面是 build.sh

#!/bin/bash

# http://blog.kablamo.org/2015/11/08/bash-tricks-eux/
set -euxo pipefail
cd "$(dirname "$0")/.."

cd aws
python3 -m venv .env && \
  source .env/bin/activate && \
  pip install aws-cdk.cdk
  pip install aws-cdk.core
  cdk synth

因此,每当我通过管道操作时,都会收到以下错误。

The directory '/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo,you may want sudo's -H flag.
The directory '/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo,you may want sudo's -H flag.
Collecting aws-cdk.s3
  Could not find a version that satisfies the requirement aws-cdk.s3 (from versions: )
No matching distribution found for aws-cdk.s3

有人可以帮我解决问题吗?任何帮助,将不胜感激。谢谢

sixupiaofubud 回答:如何使用Jenkins在AWS CDK中安装s3?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3139331.html

大家都在问