-
Notifications
You must be signed in to change notification settings - Fork 144
Fix example programs, bring the tests back to green #4159
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
package myproject; | ||
|
||
import com.pulumi.Pulumi; | ||
import com.pulumi.core.Output; | ||
import com.pulumi.aws.s3.Bucket; | ||
import com.pulumi.aws.s3.BucketPolicy; | ||
import com.pulumi.aws.s3.inputs.BucketPolicyPolicyArgs; | ||
import java.util.Map; | ||
import com.pulumi.aws.s3.BucketPolicyArgs; | ||
import static com.pulumi.codegen.internal.Serialization.*; | ||
|
||
public class App { | ||
public static void main(String[] args) { | ||
Pulumi.run(ctx -> { | ||
var bucket = new Bucket("myBucket"); | ||
|
||
var bucketArn = bucket.arn(); | ||
var policyDocument = bucketArn.apply(arn -> String.format(""" | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [{ | ||
"Effect": "Allow", | ||
"Principal": {"Service": "lambda.amazonaws.com"}, | ||
"Action": ["s3:PutObject", "s3:PutObjectAcl"], | ||
"Resource": "%s/*" | ||
}] | ||
}""", arn)); | ||
var policyDocument = bucket.arn().applyValue(arn -> serializeJson( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was necessary because Java 11 doesn't support multiline strings specified in this way. We use |
||
jsonObject( | ||
jsonProperty("Version", "2012-10-17"), | ||
jsonProperty("Statement", jsonArray(jsonObject( | ||
jsonProperty("Effect", "Allow"), | ||
jsonProperty("Action", jsonArray("s3:PutObject", "s3:PutObjectAcl")), | ||
jsonProperty("Principal", jsonObject( | ||
jsonProperty("Service", "lambda.amazonaws.com") | ||
)), | ||
jsonProperty("Resource", arn + "/*") | ||
))) | ||
) | ||
)); | ||
|
||
var bucketPolicy = new BucketPolicy("myBucketPolicy", BucketPolicyArgs.builder() | ||
.bucket(bucket.id()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,29 @@ | |
s3_bucket = aws.s3.Bucket("myBucket") | ||
|
||
# IAM Policy Document that allows the Lambda service to write to the S3 bucket | ||
s3_bucket_policy_document = s3_bucket.arn.apply(lambda arn: json.dumps({ | ||
"Version": "2012-10-17", | ||
"Statement": [{ | ||
"Effect": "Allow", | ||
"Principal": {"Service": "lambda.amazonaws.com"}, | ||
"Action": ["s3:PutObject", "s3:PutObjectAcl"], | ||
"Resource": f"{arn}/*" | ||
}] | ||
})) | ||
s3_bucket_policy_document = s3_bucket.arn.apply( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in this file are just the result of running |
||
lambda arn: json.dumps( | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Principal": {"Service": "lambda.amazonaws.com"}, | ||
"Action": ["s3:PutObject", "s3:PutObjectAcl"], | ||
"Resource": f"{arn}/*", | ||
} | ||
], | ||
} | ||
) | ||
) | ||
|
||
# Attach the policy to the bucket | ||
s3_bucket_policy = aws.s3.BucketPolicy("myBucketPolicy", | ||
s3_bucket_policy = aws.s3.BucketPolicy( | ||
"myBucketPolicy", | ||
bucket=s3_bucket.id, | ||
policy=s3_bucket_policy_document, | ||
) | ||
|
||
# Export the names and ARNs of the created resources | ||
pulumi.export('bucket_name', s3_bucket.id) | ||
pulumi.export('bucket_arn', s3_bucket.arn) | ||
pulumi.export("bucket_name", s3_bucket.id) | ||
pulumi.export("bucket_arn", s3_bucket.arn) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,19 +11,17 @@ resources: | |
properties: | ||
bucket: ${myBucket.id} | ||
policy: | ||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: "Allow" | ||
Principal: | ||
Service: "lambda.amazonaws.com" | ||
Action: | ||
- "s3:PutObject" | ||
- "s3:PutObjectAcl" | ||
Resource: | ||
Fn::Sub: "${myBucket.arn}/*" | ||
fn::toJSON: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was failing as well on a YAML-related syntax error. |
||
Version: "2012-10-17" | ||
Statement: | ||
- Effect: "Allow" | ||
Principal: | ||
Service: "lambda.amazonaws.com" | ||
Action: | ||
- "s3:PutObject" | ||
- "s3:PutObjectAcl" | ||
Resource: "${myBucket.arn}/*" | ||
|
||
outputs: | ||
bucket_name: | ||
value: ${myBucket.id} | ||
bucket_arn: | ||
value: ${myBucket.arn} | ||
bucket_name: ${myBucket.id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to export |
||
bucket_arn: ${myBucket.arn} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
module myproject | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.21.9 | ||
|
||
require ( | ||
github.com/pulumi/pulumi-awsx/sdk/v2 v2.4.0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
module awsx-vpc-azs-go | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.21.9 | ||
|
||
require ( | ||
github.com/pulumi/pulumi-awsx/sdk/v2 v2.4.0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
module awsx-vpc-go | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
toolchain go1.21.9 | ||
|
||
require ( | ||
github.com/pulumi/pulumi-awsx/sdk/v2 v2.4.0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor enhancement to make it easier to run the tests locally (so you don't have to sit through all of them again after making a fix).