Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Commit

Permalink
fix template file location and handle us-east-1 special case (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
embonshai authored Oct 3, 2022
1 parent c643245 commit 319d6ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions pkg/clients/AwsClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func (o *AwsClient) FillNotificationDetails(notification *Notification, function
}

func calculateStackTemplate(trailName string, cfg *aws.Config, config i.AWSInput) (error, string) {
templateFile := "utils/unified-template.template"
templateFile := "unified-template.template"
content, err := os.ReadFile(templateFile)
if err != nil {
return err, ""
Expand Down Expand Up @@ -617,10 +617,18 @@ func (o *AwsClient) getConfigForLambda() *aws.Config {

func uploadFuncClarityCode(cfg *aws.Config, keyPath string, bucket string) error {
s3Client := s3.NewFromConfig(*cfg)
_, err := s3Client.CreateBucket(context.TODO(), &s3.CreateBucketInput{
Bucket: aws.String(bucket),
CreateBucketConfiguration: &s3types.CreateBucketConfiguration{LocationConstraint: s3types.BucketLocationConstraint(cfg.Region)},
})
var err error
if cfg.Region != "us-east-1" {
_, err = s3Client.CreateBucket(context.TODO(), &s3.CreateBucketInput{
Bucket: aws.String(bucket),
CreateBucketConfiguration: &s3types.CreateBucketConfiguration{LocationConstraint: s3types.BucketLocationConstraint(cfg.Region)},
})
} else {
_, err = s3Client.CreateBucket(context.TODO(), &s3.CreateBucketInput{
Bucket: aws.String(bucket),
})
}

var bne *s3types.BucketAlreadyOwnedByYou
if err != nil && !errors.As(err, &bne) {
return err
Expand Down
2 changes: 1 addition & 1 deletion test/e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go build testing_lambda.go
echo "testing lambda built successfully"

cd ../..
cp ./run_env/utils/unified-template.template ./test/utils/
cp ./run_env/utils/unified-template.template ./test/
echo "stack template copied to test folder"

echo "e2e tests started"
Expand Down

0 comments on commit 319d6ca

Please sign in to comment.