我正在使用Pulumi尝试创建EBS应用程序。作为此过程的一部分,我需要将新的Docker映像推送到ECR。
在创建docker注册表之后但在beantalk应用程序版本尝试更新到新映像之前,我需要推送映像。
我有以下代码,但是希望在创建push_image_to_repository()
之后以某种方式调用ecr.Repository
(忽略丑陋的os.sytem
调用,稍后将删除它)。
application = Application(resource_name=ENV_APP_NAME, name=ENV_APP_NAME)
repository = ecr.Repository(resource_name=APP_NAME, name=APP_NAME)
image_tag = artifact_path.name.replace(".zip", "")
def push_image_to_repository(arn):
upstream = f'{arn}/{image_tag}'
os.system(f'make -C . push UPSTREAM={upstream}')
app_version = ApplicationVersion(
resource_name=ENV_APP_NAME,
application=application,
bucket=releases_bucket.id,
key=artifact_path.name,
)
environment = Environment(
application=application,
resource_name=ENV_APP_NAME,
name=ENV_APP_NAME,
solution_stack_name=STACK,
settings=BEANSTALK_ENVIRONMENT_SETTINGS,
wait_for_ready_timeout=BEANSTALK_ENVIRONMENT_TIMEOUT,
version=app_version,
)
我该怎么做?
答案 0 :(得分:0)
使用打字稿(python应该非常相似):
const repository = new aws.ecr.Repository({...})
const registry = pulumi.output(repostory.registryId).apply(async registryId => {
const credentials = await aws.ecr.getCredentials({ registryId })
const decodedCredentials = Buffer.from(credentials.authorizationToken, "base64").toString()
const [username, password] = decodedCredentials.split(":")
return { server: credentials.proxyEndpoint, username, password }
})
new docker.Image('my-image', {
build: { context: '...' },
imageName: pulumi.interpolate`${repository.repositoryUrl}:my-tag`,
registry: registry,
})