https://pulumi.com logo
#aws
Title
# aws
b

busy-lion-51883

03/04/2022, 8:06 PM
Is there a way to force the output of the
pulumi.Config("aws").require("region")
to confrom to type Region. For example:
Copy code
const region = new pulumi.Config("aws").require('region');

const codepipelinesProvider = new aws.Provider("codepipelinesProvider", {
  profile: CODEPIPELINES_PROFILE_ID,
  region: region,
});
in this case I get a type mismatch error:
Type string is not assignable to Type Input
would the following be adviseable:
Copy code
const region: aws.Region = new pulumi.Config("aws").require('region');
b

billowy-army-68599

03/04/2022, 8:35 PM
@busy-lion-51883 you'd need to use an
apply
for this, as the config is retrieved async
also, the config setting is global, so unless you need an explicit provider you probably don't actually need to do this
b

busy-lion-51883

03/04/2022, 8:41 PM
it appears to work without using apply. Is the recommendation to use apply in order to get it functional or to avoid some sort of undesirable side effect?
b

billowy-army-68599

03/04/2022, 8:59 PM
it may not always behave as expected, but if it works that's great. if you see anyweird behaviour, let us know
j

jolly-alligator-19698

03/04/2022, 9:26 PM
@billowy-army-68599 https://www.pulumi.com/docs/intro/concepts/config/ doesn't have any examples using
apply
, they're all using plain
require*()
or
get*()
. Is the need for
apply
an omission in that documentation?
b

billowy-army-68599

03/05/2022, 12:12 AM
@jolly-alligator-19698 the examples show you how to retrieve a configuration item from the config stack. the values as retrieved as
Input<T>
and usually, you'd pass those values to another resource which take an
Input<T>
However, if you need to pass a value to a resource which is a string, you'd need to use an
apply
It looks like the region can be tInputty typein this case, so an apply is not needed, I should have checked before commenting
👍 1
23 Views