Hey girls/guys, sorry for the stupid question but ...
# general
Hey girls/guys, sorry for the stupid question but I have trouble to understand what Pulumi documentation means by the ID of a resource and thus how to get an existing AWS resource (say, a AWS DataSource, or a DynamoDB table, whatever) with Pulumi (in my case in Python). Pulumi documentation (https://www.pulumi.com/docs/intro/concepts/resources/get/) says the getter function should be provided the name of the resource (got that), but also the ID. What is the ID of the resource? I tried with the AWS ARN of the resource, but got a Pulumi error. Might be a stupid question but I’m stuck on this one for an hour!
So it's normally the last part of the arn. So something with an arn like "arnawsec2us west 2616138583583:instance/i-092bcc5cbb92278c1" has an id of "i-092bcc5cbb92278c1".
🙏 1
Oh ok. Thanks. This is the only way the get the ID?
I mean, I have to know the ID? I cannot get a resource just from its name?
Currently you need the ID, we don't have a general search by other fields system yet.
@steep-lamp-20408 There is a difference between the
function on any Resource class (which needs the id as @echoing-dinner-19531 described) and similar functions you see on the package level. In your case, you are more interested in
where you can pass a filter description. https://www.pulumi.com/registry/packages/aws/api-docs/ec2/getinstance/
🙏 1
👀 1
Thanks @echoing-dinner-19531 and @limited-rainbow-51650
@limited-rainbow-51650 Although I need to get a DataSource and a DynamoDB table, according to the doc there is no
for AWS DataSources and DynamoDB tables Pulumi types. Right?
The word
refers to an EC2 instance. This isn’t a function that returns you an instance of any resource type. E.g. for DynamoDB tables, you have a similar function in the
module: https://www.pulumi.com/registry/packages/aws/api-docs/dynamodb/gettable/ There seems to be more than one AWS product which has a type
. Which product are you using in this case?
@limited-rainbow-51650 Thanks. Great for DynamoDB, missed that! For
sorry I mean an AppSync DataSource, if that makes things more clear.
@limited-rainbow-51650 For Appsync DataSource I see a
function but it seems it requires an ID: https://www.pulumi.com/registry/packages/aws/api-docs/appsync/datasource/
I couldn’t find any ARN or ID for AppSync DataSource in AWS.
In that case I might just recreate another DataSource and associate it with the same existing DynamoDB table.
I figured it out thanks to the help of @limited-rainbow-51650. If that can be of any help to someone else, this is how you get an existing AWS DynamoDB table from its name (in Python). You need to do it in two steps. The documentation is not clear on that and on what is an ID (blink to Pulumi’s team, would be great to improve the doc on that points) Here you are (I type-hinted the vars for more clarity):
Copy code
import pulumi_aws as aws

dynamodb_table_info: aws.dynamodb.get_table.AwaitableGetTableResult = aws.dynamodb.get_table(name="my-name")

dynamodb_table: aws.dynamodb.Table = aws.dynamodb.Table.get(resource_name=dynamodb_table_info.name, id=dynamodb_table_info.id)