This article is a memorandum from S3 to INSERT data to DB on EC2 via Lambda (java). (As of 09/2018) This is my first post, so please look at it with warm eyes. (You are welcome to point out. Please comment.)
1: AWS edition 2: Java part [Part 1] 3: Java [Part 2] 3.5: Java version [continued]
Log in to the AWS Management Console and open the IAM dashboard.
Select "User" from the navigation bar on the left side of the screen. Create a user for S3 access from [Add User] at the top left of the screen. For later use, check "Programmatic access" in "Access type".
[Next step: Access authority] will take you to the access authority setting page, so select the block [Attach existing policy directly] on the right and select Filter the policy with "S3".
Some will be listed, so this time check the permissions for full access (read / wirte). Since the boundary is not set, go to the next step.
A confirmation screen will be displayed. After confirming that the user name and management policy are correct, click [Create User] at the bottom center of the screen to complete the creation of the user who has been granted the IAM role.
Let's create a VPC to which the EC2 instance belongs.
Access the VPC console. When you select [Create VPC] at the top of the screen, a pop-up will appear. Enter the VPC name (optional) and the IPv4 CIDR block. Determine the address range according to the number of instances you need.
After you create your VPC, create a subnet within your VPC. Select "Subnet" from the navigation bar on the left side of the screen and click [Create Subnet] at the top. Enter the subnet name (optional), select the VPC you created earlier, and create a subnet.
Next, create an SSH entrance to connect to the created EC2 instance from the outside. Select "Internet Gateway" from the navigation bar of the VPC console. Similarly, click [Create Internet Gateway] from the top of the screen to create a gateway (Name tag is optional).
The gateway you just created is not tied to the VPC (not attached), so From [Action]-> "Attach to VPC", attach to the test_vpc created earlier. After attaching to the VPC, select "Route Table" from the navigation bar on the left side of the screen.
When you select the created VPC (test_vpc), the details of the VPC route information will be displayed at the bottom of the screen, so With the [Route] tab selected, click [Edit] to add a route.
Set the destination to 0.0.0.0/0 and move the cursor to the target, the gateway ID will be displayed, so click it. Click [Save] to confirm the edit.
This completes the VPC area settings.
Select Create Instance from the EC2 dashboard. Basically, it just pops according to the screen, but the specifications this time are as follows.
Instance type: t2.medium
OS | disk | File System | vCPU | Mem |
---|---|---|---|---|
RHEL 7.5 | 10GB | xfs | 2 cores | 4GB |
DB has installed SQL Server (Express).
After connecting to the S3 management console, click [+ Create bucket] at the top left of the screen.
Proceed as follows according to the wizard.
The bucket name must be unique. This time, we will proceed with the defaults for ② and ③ of the wizard. After confirming that the input items are correct on the confirmation screen of ④, click [Create bucket]. Make sure the bucket was created successfully.Next, let's upload an appropriate file with the [Upload] button at the top of the screen.
Here, the following CSV is created and uploaded.
test_people.csv
Id,Name,Age
1001,Dean,28
1002,Sam,25
1003,John,51
1004,Bobby,54
1005,Meg,26
Next time, I would like to get the information of this uploaded file by executing the Lambda function.
~~ (I forgot to take a capture) ~~ The EC2 part has been omitted. m (_ _) m The java edition will be posted soon.
Recommended Posts