简体   繁体   English

如何用Pulumi导入已有的S3 object?

[英]How to import an existing S3 object with Pulumi?

I am trying to import an existing S3 object into Pulumi.我正在尝试将现有的 S3 object 导入 Pulumi。 This is my current attempt (using Python):这是我目前的尝试(使用 Python):

bucket = s3.Bucket('test-bucket',
               bucket='test-bucket')
file = s3.BucketObject('file.txt',
                   bucket=bucket,
                   key='temp/file.txt',
                   opts=ResourceOptions(import_='temp/file.txt'))

With that config, I am getting the following error:使用该配置,我收到以下错误:

Diagnostics:
  aws:s3:BucketObject (file.txt):
    error: Preview failed: refreshing urn:pulumi:dev::quickstart::aws:s3/bucketObject:BucketObject::file.txt: 1 error occurred:
        * InvalidParameter: 2 validation error(s) found.
    - minimum field size of 1, HeadObjectInput.Bucket.
    - minimum field size of 1, HeadObjectInput.Key.

I could not find any mention of a HeadObjectInput in the reference documentation .我在 参考文档中找不到任何提及HeadObjectInput的地方。

What parameters should I pass to BucketObject() so that the S3 object is imported in Pulumi?我应该将哪些参数传递给BucketObject()以便在 Pulumi 中导入 S3 object?

My final goal here is to use Pulumi to delete an existing object from an S3 bucket.我的最终目标是使用 Pulumi 从 S3 存储桶中删除现有的 object。 Is there any other way for achieving this?还有其他方法可以实现这一目标吗?

Currently, the Pulumi aws provider is built on the terraform aws provider.目前,Pulumi aws provider 是建立在 terraform aws provider 之上的。 So, I tried importing an S3 bucket and S3 bucket object in terraform. Although the bucket imports in terraform (and Pulumi), terraform throws an error:因此,我尝试在 terraform 中导入 S3 存储桶和 S3 存储桶 object。虽然存储桶在 terraform(和 Pulumi)中导入,但 terraform 会引发错误:

Error: resource aws_s3_bucket_object doesn't support import

Therefore, the Pulumi provider (at this time) does not support it either.因此,Pulumi 提供商(此时)也不支持它。

If you are indeed trying to import an existing bucket and/or object for Pulumi to manage as part of the stack, this page may help: https://www.pulumi.com/docs/guides/adopting/import/如果您确实正在尝试导入现有存储桶和/或 object 以便 Pulumi 作为堆栈的一部分进行管理,此页面可能会有所帮助: https://www.pulumi.com/docs/guides/adopting/import/

If you just want to get information about an existing bucket and/or object, then there are get functions available: https://www.pulumi.com/docs/reference/pkg/aws/s3/#functions如果您只想获取有关现有存储桶和/或 object 的信息,则可以使用获取函数: https://www.pulumi.com/docs/reference/pkg/aws/s3/#functions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM