File tree Expand file tree Collapse file tree 5 files changed +37
-21
lines changed Expand file tree Collapse file tree 5 files changed +37
-21
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -eo pipefail
3
+ OUTPUT_BUCKET=$( aws cloudformation describe-stack-resource --stack-name blank --logical-resource-id bucket --query ' StackResourceDetail.PhysicalResourceId' --output text)
4
+ while true ; do
5
+ read -p " Delete output bucket ($OUTPUT_BUCKET )?" response
6
+ case $response in
7
+ [Yy]* ) aws s3 rb --force s3://$OUTPUT_BUCKET ; aws cloudformation delete-stack --stack-name blank; break ;;
8
+ [Nn]* ) aws cloudformation delete-stack --stack-name blank --retain-resources bucket; exit ;;
9
+ * ) echo " Response must start with y or n." ;;
10
+ esac
11
+ done
12
+ echo " Deleted function stack"
3
13
aws cloudformation delete-stack --stack-name blank
4
14
if [ -f bucket-name.txt ]; then
5
15
ARTIFACT_BUCKET=$( cat bucket-name.txt)
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
set -eo pipefail
3
+ cd function
4
+ npm install --production
5
+ cd ../
3
6
aws cloudformation package --template-file template.yaml --s3-bucket MY_BUCKET --output-template-file out.yml
4
7
aws cloudformation deploy --template-file out.yml --stack-name blank --capabilities CAPABILITY_NAMED_IAM
Original file line number Diff line number Diff line change @@ -4,24 +4,6 @@ Description: An AWS Lambda application that uses AWS X-Ray and Amazon S3.
4
4
Resources :
5
5
bucket :
6
6
Type : AWS::S3::Bucket
7
- role :
8
- Type : AWS::IAM::Role
9
- Properties :
10
- AssumeRolePolicyDocument :
11
- Version : " 2012-10-17"
12
- Statement :
13
- -
14
- Effect : Allow
15
- Principal :
16
- Service :
17
- - lambda.amazonaws.com
18
- Action :
19
- - sts:AssumeRole
20
- ManagedPolicyArns :
21
- - arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess
22
- - arn:aws:iam::aws:policy/AmazonS3FullAccess
23
- - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
24
- Path : /service-role/
25
7
function :
26
8
Type : AWS::Serverless::Function
27
9
Properties :
@@ -31,7 +13,18 @@ Resources:
31
13
Description : Write a file to S3.
32
14
MemorySize : 128
33
15
Timeout : 10
34
- Role : !GetAtt role.Arn
16
+ # Function's execution role
17
+ Policies :
18
+ - AWSLambdaBasicExecutionRole
19
+ - AmazonS3FullAccess
20
+ - AWSXrayWriteOnlyAccess
21
+ - AWSLambdaVPCAccessExecutionRole
22
+ VpcConfig :
23
+ SecurityGroupIds :
24
+ - Fn::ImportValue : lambda-vpc-private-vpc-sg
25
+ SubnetIds :
26
+ - Fn::ImportValue : lambda-vpc-private-subnet-a
27
+ - Fn::ImportValue : lambda-vpc-private-subnet-b
35
28
Environment :
36
29
Variables :
37
30
bucket : !Ref bucket
Original file line number Diff line number Diff line change @@ -94,4 +94,9 @@ Outputs:
94
94
Description : Private Subnet B ID
95
95
Value : !Ref privateSubnet2
96
96
Export :
97
- Name : !Join ["-", [!Ref "AWS::StackName","subnet-b"]]
97
+ Name : !Join ["-", [!Ref "AWS::StackName","subnet-b"]]
98
+ privateVPCSecurityGroup :
99
+ Description : Default security for Lambda VPC
100
+ Value : !GetAtt privateVPC.DefaultSecurityGroup
101
+ Export :
102
+ Name : !Join ["-", [!Ref "AWS::StackName","vpc-sg"]]
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ Resources:
137
137
ServiceName : !Sub com.amazonaws.${AWS::Region}.dynamodb
138
138
VpcId : !Ref pubPrivateVPC
139
139
Outputs :
140
- privateVPCID :
140
+ pubPrivateVPCID :
141
141
Description : VPC ID
142
142
Value : !Ref pubPrivateVPC
143
143
Export :
@@ -157,5 +157,10 @@ Outputs:
157
157
Value : !Ref privateSubnet2
158
158
Export :
159
159
Name : !Join ["-", [!Ref "AWS::StackName","private-subnet-b"]]
160
+ privateVPCSecurityGroup :
161
+ Description : Default security for Lambda VPC
162
+ Value : !GetAtt pubPrivateVPC.DefaultSecurityGroup
163
+ Export :
164
+ Name : !Join ["-", [!Ref "AWS::StackName","vpc-sg"]]
160
165
161
166
You can’t perform that action at this time.
0 commit comments