Skip to content

Commit

Permalink
Cascade-replace resources when provider region changes (#3497)
Browse files Browse the repository at this point in the history
Fixes scenario described in
pulumi/pulumi-terraform-bridge#244 (comment)

It is now possible to change region at the provider level, in which case
Pulumi will replace all resources provisioned against that provider in
the new region. Unlike Pulumi, TF proper does not work in this case and
changing a region causes authentication failures.
  • Loading branch information
t0yv0 authored Apr 15, 2024
1 parent 82ce75c commit d12eda4
Show file tree
Hide file tree
Showing 53 changed files with 2,046 additions and 3,531 deletions.
1 change: 1 addition & 0 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ func ProviderFromMeta(metaInfo *tfbridge.MetadataInfo) *tfbridge.ProviderInfo {
Default: &tfbridge.DefaultInfo{
EnvVars: []string{"AWS_REGION", "AWS_DEFAULT_REGION"},
},
ForcesProviderReplace: tfbridge.True(),
},
"skip_region_validation": {
Default: &tfbridge.DefaultInfo{
Expand Down
2 changes: 1 addition & 1 deletion provider/test-programs/bucket/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ resources:
tested-resource:
type: aws:s3/bucket:Bucket
properties:
bucket: testbucket-${pulumi.stack}
bucket: pulumiawstestbucket-${pulumi.stack}
options:
provider: ${provider}
8 changes: 4 additions & 4 deletions provider/test-programs/iam-instanceprofile/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

name: "aws_iam_instanceProfile_InstanceProfile_1"
runtime: yaml

resources:
test_profile:
type: aws:iam:InstanceProfile
Expand All @@ -11,14 +11,14 @@ resources:
role:
type: aws:iam:Role
properties:
name: test_role
name: pulumi_aws_test_role_${pulumi.stack}
path: /
assumeRolePolicy: ${assumeRole.json}
variables:
assumeRole:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
function: aws:iam:getPolicyDocument
arguments:
statements:
- effect: Allow
principals:
Expand Down

Large diffs are not rendered by default.

161 changes: 85 additions & 76 deletions ...er/testdata/recorded/TestProviderUpgrade/apigateway-integrationresponse/5.42.0/stack.json
100755 → 100644

Large diffs are not rendered by default.

Large diffs are not rendered by default.

140 changes: 75 additions & 65 deletions provider/testdata/recorded/TestProviderUpgrade/apigateway-methodreponse/5.42.0/stack.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,115 +2,125 @@
"version": 3,
"deployment": {
"manifest": {
"time": "2023-11-10T17:23:05.006273-05:00",
"magic": "7a709c148c841bd111f454593cb3e2e763c9bdd1e384d02234b29bc070e10e78",
"version": "v3.92.0"
"time": "2024-04-15T15:43:44.920028-04:00",
"magic": "0e109972342b6ebd571fa6d2cffefcb95394f9c4f7bdd855463082d16126072c",
"version": "v3.111.1"
},
"secrets_providers": {
"type": "passphrase",
"state": {
"salt": "v1:6d1Qq1wIc9c=:v1:MzIicgMpnxidEKdL:J7DiXS+xanaSAys5vVuyUOqpYM8ZvQ=="
"salt": "v1:5UM/bBIth18=:v1:kgisfsCU5rUOTefT:8ikmBnkaWU3d486FcQmekWZEesHvKQ=="
}
},
"resources": [
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:pulumi:Stack::aws_apigateway_methodResponse_MethodResponse_1-test",
"custom": false,
"type": "pulumi:pulumi:Stack",
"created": "2023-11-10T22:23:00.499782Z",
"modified": "2023-11-10T22:23:00.499782Z"
"created": "2024-04-15T19:43:38.845453Z",
"modified": "2024-04-15T19:43:38.845453Z"
},
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default",
"custom": true,
"id": "19f04ff8-cf1c-4d97-be78-14613ed05740",
"id": "a1f4c496-0c1f-43dd-9732-b9cb5aa1f4f4",
"type": "pulumi:providers:aws",
"created": "2023-11-10T22:23:02.025248Z",
"modified": "2023-11-10T22:23:02.025248Z"
"inputs": {
"region": "us-west-2",
"skipCredentialsValidation": "false",
"skipMetadataApiCheck": "true",
"skipRegionValidation": "true"
},
"outputs": {
"region": "us-west-2",
"skipCredentialsValidation": "false",
"skipMetadataApiCheck": "true",
"skipRegionValidation": "true"
},
"created": "2024-04-15T19:43:42.157126Z",
"modified": "2024-04-15T19:43:42.157126Z"
},
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI",
"custom": true,
"id": "v1ve06ocl6",
"id": "vs00x5mu1h",
"type": "aws:apigateway/restApi:RestApi",
"inputs": {
"__defaults": [
"minimumCompressionSize",
"putRestApiMode"
],
"description": "This is my API for demonstration purposes",
"minimumCompressionSize": -1,
"name": "MyDemoAPI",
"putRestApiMode": "overwrite"
},
"outputs": {
"apiKeySource": "HEADER",
"arn": "arn:aws:apigateway:us-west-2::/restapis/v1ve06ocl6",
"arn": "arn:aws:apigateway:us-west-2::/restapis/vs00x5mu1h",
"binaryMediaTypes": [],
"createdDate": "2023-11-10T22:23:03Z",
"createdDate": "2024-04-15T19:43:43Z",
"description": "This is my API for demonstration purposes",
"disableExecuteApiEndpoint": false,
"endpointConfiguration": {
"types": "EDGE",
"vpcEndpointIds": []
},
"executionArn": "arn:aws:execute-api:us-west-2:616138583583:v1ve06ocl6",
"id": "v1ve06ocl6",
"minimumCompressionSize": -1,
"executionArn": "arn:aws:execute-api:us-west-2:616138583583:vs00x5mu1h",
"id": "vs00x5mu1h",
"minimumCompressionSize": "",
"name": "MyDemoAPI",
"policy": "",
"rootResourceId": "6l6ql3hnui",
"rootResourceId": "bvcaesigfj",
"tags": {},
"tagsAll": {}
},
"parent": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:pulumi:Stack::aws_apigateway_methodResponse_MethodResponse_1-test",
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::19f04ff8-cf1c-4d97-be78-14613ed05740",
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::a1f4c496-0c1f-43dd-9732-b9cb5aa1f4f4",
"propertyDependencies": {
"description": null,
"name": null
"description": [],
"name": []
},
"created": "2023-11-10T22:23:04.256536Z",
"modified": "2023-11-10T22:23:04.256536Z"
"created": "2024-04-15T19:43:44.195383Z",
"modified": "2024-04-15T19:43:44.195383Z"
},
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/resource:Resource::MyDemoResource",
"custom": true,
"id": "owzlrx",
"id": "xc671u",
"type": "aws:apigateway/resource:Resource",
"inputs": {
"__defaults": [],
"parentId": "6l6ql3hnui",
"parentId": "bvcaesigfj",
"pathPart": "mydemoresource",
"restApi": "v1ve06ocl6"
"restApi": "vs00x5mu1h"
},
"outputs": {
"id": "owzlrx",
"parentId": "6l6ql3hnui",
"id": "xc671u",
"parentId": "bvcaesigfj",
"path": "/mydemoresource",
"pathPart": "mydemoresource",
"restApi": "v1ve06ocl6"
"restApi": "vs00x5mu1h"
},
"parent": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:pulumi:Stack::aws_apigateway_methodResponse_MethodResponse_1-test",
"dependencies": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::19f04ff8-cf1c-4d97-be78-14613ed05740",
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::a1f4c496-0c1f-43dd-9732-b9cb5aa1f4f4",
"propertyDependencies": {
"parentId": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"pathPart": null,
"pathPart": [],
"restApi": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
]
},
"created": "2023-11-10T22:23:04.552754Z",
"modified": "2023-11-10T22:23:04.552754Z"
"created": "2024-04-15T19:43:44.482578Z",
"modified": "2024-04-15T19:43:44.482578Z"
},
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/method:Method::MyDemoMethod",
"custom": true,
"id": "agm-v1ve06ocl6-owzlrx-GET",
"id": "agm-vs00x5mu1h-xc671u-GET",
"type": "aws:apigateway/method:Method",
"inputs": {
"__defaults": [
Expand All @@ -119,53 +129,53 @@
"apiKeyRequired": false,
"authorization": "NONE",
"httpMethod": "GET",
"resourceId": "owzlrx",
"restApi": "v1ve06ocl6"
"resourceId": "xc671u",
"restApi": "vs00x5mu1h"
},
"outputs": {
"apiKeyRequired": false,
"authorization": "NONE",
"httpMethod": "GET",
"id": "agm-v1ve06ocl6-owzlrx-GET",
"resourceId": "owzlrx",
"restApi": "v1ve06ocl6"
"id": "agm-vs00x5mu1h-xc671u-GET",
"resourceId": "xc671u",
"restApi": "vs00x5mu1h"
},
"parent": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:pulumi:Stack::aws_apigateway_methodResponse_MethodResponse_1-test",
"dependencies": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/resource:Resource::MyDemoResource",
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::19f04ff8-cf1c-4d97-be78-14613ed05740",
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::a1f4c496-0c1f-43dd-9732-b9cb5aa1f4f4",
"propertyDependencies": {
"authorization": null,
"httpMethod": null,
"authorization": [],
"httpMethod": [],
"resourceId": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/resource:Resource::MyDemoResource"
],
"restApi": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
]
},
"created": "2023-11-10T22:23:04.713501Z",
"modified": "2023-11-10T22:23:04.713501Z"
"created": "2024-04-15T19:43:44.634843Z",
"modified": "2024-04-15T19:43:44.634843Z"
},
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/methodResponse:MethodResponse::response_200",
"custom": true,
"id": "agmr-v1ve06ocl6-owzlrx-GET-200",
"id": "agmr-vs00x5mu1h-xc671u-GET-200",
"type": "aws:apigateway/methodResponse:MethodResponse",
"inputs": {
"__defaults": [],
"httpMethod": "GET",
"resourceId": "owzlrx",
"restApi": "v1ve06ocl6",
"resourceId": "xc671u",
"restApi": "vs00x5mu1h",
"statusCode": "200"
},
"outputs": {
"httpMethod": "GET",
"id": "agmr-v1ve06ocl6-owzlrx-GET-200",
"resourceId": "owzlrx",
"restApi": "v1ve06ocl6",
"id": "agmr-vs00x5mu1h-xc671u-GET-200",
"resourceId": "xc671u",
"restApi": "vs00x5mu1h",
"statusCode": "200"
},
"parent": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:pulumi:Stack::aws_apigateway_methodResponse_MethodResponse_1-test",
Expand All @@ -174,7 +184,7 @@
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/resource:Resource::MyDemoResource",
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::19f04ff8-cf1c-4d97-be78-14613ed05740",
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::a1f4c496-0c1f-43dd-9732-b9cb5aa1f4f4",
"propertyDependencies": {
"httpMethod": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/method:Method::MyDemoMethod"
Expand All @@ -185,15 +195,15 @@
"restApi": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"statusCode": null
"statusCode": []
},
"created": "2023-11-10T22:23:04.865088Z",
"modified": "2023-11-10T22:23:04.865088Z"
"created": "2024-04-15T19:43:44.794514Z",
"modified": "2024-04-15T19:43:44.794514Z"
},
{
"urn": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/integration:Integration::MyDemoIntegration",
"custom": true,
"id": "agi-v1ve06ocl6-owzlrx-GET",
"id": "agi-vs00x5mu1h-xc671u-GET",
"type": "aws:apigateway/integration:Integration",
"inputs": {
"__defaults": [
Expand All @@ -202,26 +212,26 @@
],
"connectionType": "INTERNET",
"httpMethod": "GET",
"resourceId": "owzlrx",
"restApi": "v1ve06ocl6",
"resourceId": "xc671u",
"restApi": "vs00x5mu1h",
"timeoutMilliseconds": 29000,
"type": "MOCK"
},
"outputs": {
"cacheKeyParameters": [],
"cacheNamespace": "owzlrx",
"cacheNamespace": "xc671u",
"connectionId": "",
"connectionType": "INTERNET",
"contentHandling": "",
"credentials": "",
"httpMethod": "GET",
"id": "agi-v1ve06ocl6-owzlrx-GET",
"id": "agi-vs00x5mu1h-xc671u-GET",
"integrationHttpMethod": "",
"passthroughBehavior": "WHEN_NO_MATCH",
"requestParameters": {},
"requestTemplates": {},
"resourceId": "owzlrx",
"restApi": "v1ve06ocl6",
"resourceId": "xc671u",
"restApi": "vs00x5mu1h",
"timeoutMilliseconds": 29000,
"tlsConfig": null,
"type": "MOCK",
Expand All @@ -233,7 +243,7 @@
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/resource:Resource::MyDemoResource",
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::19f04ff8-cf1c-4d97-be78-14613ed05740",
"provider": "urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::pulumi:providers:aws::default::a1f4c496-0c1f-43dd-9732-b9cb5aa1f4f4",
"propertyDependencies": {
"httpMethod": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/method:Method::MyDemoMethod"
Expand All @@ -244,10 +254,10 @@
"restApi": [
"urn:pulumi:test::aws_apigateway_methodResponse_MethodResponse_1::aws:apigateway/restApi:RestApi::MyDemoAPI"
],
"type": null
"type": []
},
"created": "2023-11-10T22:23:05.006089Z",
"modified": "2023-11-10T22:23:05.006089Z"
"created": "2024-04-15T19:43:44.919849Z",
"modified": "2024-04-15T19:43:44.919849Z"
}
]
}
Expand Down
Loading

0 comments on commit d12eda4

Please sign in to comment.