Как установить s3 в aws cdk с помощью Jenkins? - PullRequest
0 голосов
/ 08 ноября 2019

Привет, я работаю над AWS cdk, чтобы создать s3 bucket. Я использую свой корпоративный Дженкинс для создания конвейера. Ниже приведен мой код на Python для создания корзины s3.

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

Может кто-нибудь помочь мне разобраться в проблеме? Любая помощь будет оценена. Спасибо

...