I have a Route53 record in a different AWS account...
# python
j
I have a Route53 record in a different AWS account from where our pulumi stack is deployed, and I need to be able to update this record as part of my pulumi deploy. I've created a provider to use as part of updating my record but I get an error when I run pulumi up, "no matching Route53Zone found". Has anyone needed to update a route53 record in a different AWS account with a new alb dns name?
Copy code
dns_provider = aws.Provider(
    'dns',
    region = 'us-east-1',
    profile = 'my_local_aws_profile_for dev account',
    assume_role = aws.ProviderAssumeRoleArgs(
        role_arn = "my_arn_where_route53_record_resides"        
    )
)

record = aws.route53.Record(
    "data-viz",
    zone_id = aws.route53.get_zone(name = "my_domain.com."),
    name = "<http://myrecord.my_domain.com|myrecord.my_domain.com>",
    type = "CNAME",
    aliases = [aws.route53.RecordAliasArgs(
        name = alb.load_balancer.dns_name,
        zone_id = alb.load_balancer.zone_id,
        evaluate_target_health = True 
    )],
    opts=pulumi.ResourceOptions(provider = dns_provider)
)
b
that needs the provider passed to it
j
@billowy-army-68599 I thought I did pass it. It's down below the aliases line. Is that not correct?
b
you’re passing it to the resource creation itself, however the
get_zone
call it actually a different operation (called an invoke) which doesn’t use the resource provider
if you wrote it like this:
Copy code
dns_provider = aws.Provider(
    'dns',
    region = 'us-east-1',
    profile = 'my_local_aws_profile_for dev account',
    assume_role = aws.ProviderAssumeRoleArgs(
        role_arn = "my_arn_where_route53_record_resides"        
    )
)

zone = aws.route53.get_zone(name = "my_domain.com.", opts=provider),

record = aws.route53.Record(
    "data-viz",
    zone_id = zone,
    name = "<http://myrecord.my_domain.com|myrecord.my_domain.com>",
    type = "CNAME",
    aliases = [aws.route53.RecordAliasArgs(
        name = alb.load_balancer.dns_name,
        zone_id = alb.load_balancer.zone_id,
        evaluate_target_health = True 
    )],
    opts=pulumi.ResourceOptions(provider = dns_provider)
)
it might help understand what I’m saying
j
Sorry @billowy-army-68599 I'm still not understanding. While I'm not getting the "can't find domain" error I am still getting an message I don't understand. raise TypeError("Expected opts2 to be a InvokeOptions instance") TypeError: Expected opts2 to be a InvokeOptions instance
Copy code
# Create the Pulumi provider to use when calling to another AWS account
dns_provider = aws.Provider(
    'dns',
    region = 'us-east-1',
    profile = 'profile_name_where_stack_is_deployed',
    assume_role = aws.ProviderAssumeRoleArgs(
        role_arn = "arn_of_role_in_same_account_as_stack"        
    )
)

# Get zone information for record
zone = aws.route53.get_zone(name="my_domain.com.", opts=pulumi.ResourceOptions(provider=dns_provider))

record = aws.route53.Record(
    "data-viz",
    zone_id = zone.id,
    name = "record.my_domain.com.",
    type = "CNAME",
    aliases = [aws.route53.RecordAliasArgs(
        name = alb.load_balancer.dns_name,
        zone_id = alb.load_balancer.zone_id,
        evaluate_target_health = True
    )],
    opts=pulumi.ResourceOptions(provider=dns_provider)
)
I get this error where I defined 'zone'
b
you’re passing a ResourceOptions to an invoke, you need to pass an
pulumi.InvokeOptions
j
Oh, I see. Thank you @billowy-army-68599 . That fixed my issue.
My only question is when "when is it appropriate to call ResourceOptions, and when is it appropriate to call InvokeOptions"?
b
ResourceOptions is when you create a new resource, invoke options is for when you use a
get_something
function
275 Views