-
Notifications
You must be signed in to change notification settings - Fork 882
Upgrade AWS provider to v7 and remove deprecated BucketV2 classes #2192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8f95ae1
Refactor S3 Bucket resources to use AWS v7 provider
CamSoper dbfae96
Improve exception formatting for role and domain configuration checks
CamSoper f95d4f8
Apply suggestion from @Copilot
CamSoper 68990a0
Merge remote-tracking branch 'origin/master' into CamSoper/docs/issue…
CamSoper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
# Copyright 2016-2020, Pulumi Corporation. All rights reserved. | ||
|
||
import pulumi_aws as aws | ||
from pulumi import Config, ResourceOptions, export | ||
from pulumi import Config, ResourceOptions, export, runtime | ||
|
||
config = Config() | ||
role_to_assume_arn = config.require("roleToAssumeARN") | ||
aws_config = Config("aws") | ||
|
||
provider = aws.Provider( | ||
"privileged", | ||
assume_roles=[ | ||
{ | ||
"role_arn": role_to_assume_arn, | ||
# session name can contain only the following special characters =,.@- | ||
# if any other special character is used, an error stating that the role | ||
# cannot be assumed will be returned | ||
"session_name": "PulumiSession", | ||
"externalId": "PulumiApplication", | ||
} | ||
], | ||
region=aws_config.require("region"), | ||
) | ||
is_preview = runtime.is_dry_run() | ||
# Apply-time guard: prevent using preview placeholder on apply | ||
if not is_preview and role_to_assume_arn.startswith("arn:aws:iam::123456789012:role/preview-"): | ||
raise Exception( | ||
"Configure a real roleToAssumeARN before 'pulumi up'. Example: pulumi config set aws-py-assume-role:roleToAssumeARN arn:aws:iam::<account>:role/<roleName>" | ||
) | ||
if is_preview: | ||
provider = aws.Provider( | ||
"privileged", | ||
region=aws_config.require("region"), | ||
) | ||
else: | ||
provider = aws.Provider( | ||
"privileged", | ||
region=aws_config.require("region"), | ||
assume_roles=[ | ||
{ | ||
"role_arn": role_to_assume_arn, | ||
# session name can contain only the following special characters =,.@- | ||
# if any other special character is used, an error stating that the role | ||
# cannot be assumed will be returned | ||
"session_name": "PulumiSession", | ||
"externalId": "PulumiApplication", | ||
} | ||
], | ||
) | ||
|
||
# Creates an AWS resource (S3 Bucket) | ||
bucket = aws.s3.BucketV2("my-bucket", opts=ResourceOptions(provider=provider)) | ||
bucket = aws.s3.Bucket("my-bucket", opts=ResourceOptions(provider=provider)) | ||
|
||
# Exports the DNS name of the bucket | ||
export("bucket_name", bucket.bucket_domain_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.