Reputation: 3907
I'm new to AWS CDK and what I need is to deploy around 10 function that are currently stored as zip file inside a S3 Bucket
Here's the portion of the code I use
public class CdkWorkshopStack : Stack
{
public CdkWorkshopStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
var deployBucket = new Bucket(this, "deploy-stack1");
var bucketKey = "xxx-3496f166-0f1d-40b4-8766-c5d29e4950ff.zip";
var xxx= new Function(this, "CdkWorkshopLambda", new FunctionProps
{
Runtime = Runtime.DOTNET_6,
Code = Code.FromBucket(bucket: deployBucket, key: bucketKey),
Handler = "app.handler",
Environment = new Dictionary<string, string>
{
["DELETE_S3_FILE_AFTER_PROCESSING"] = "true",
["TMP_DOWNLOAD_BUCKET"] = "content-temporary-files"
},
FunctionName = "xxx",
Architecture = Architecture.X86_64,
Description = "Calculates the xxx for a given filename"
});
Now my problem is the following, I need to read from a bucket that's now present in the enviorment I'm creating (since the bucket can be considered as a repo)
how can I specify a bucket that's external to the account/region?
Thanks in advance
Upvotes: 1
Views: 3133
Reputation: 11559
By using Bucket.fromBucketArn
and providing the ARN.
You'll have to make sure you have the required rights to access this bucket cross-account.
Upvotes: 1