Recently, we are developing using AWS CodeStar. CodeStar is roughly understood as a service that combines a CI / CD service and a dashboard. The CI / CD tool is also packaged and created, so the code you write will be reflected immediately, which is convenient when you want to give it a try. However, when I made it (I am a beginner of AWS), I often stumbled around the authority. We plan to update S3 access, Lambda VPC placement, and EC2 projects from time to time.
First, edit and push the code with a local text editor to check the changes.
--Work date: 2020/4/11 --Local environment
Open the CodeStar service by searching for codestar from the AWS Management Console
Create a new project
This time select the "Python Web Service Lambda" template
This time, the project name is "hello-world-codestar", the project ID is "codestar-test", and the repository uses CodeCommit.
Creating a project ... after the creation is completed
In this state, you can check the response from Lambda of the initial template by accessing "Application Endpoint" in the dashboard.
Clone the URL copied by the CLI of the local machine, in the case of the first clone [Git credentials](https://docs.aws.amazon.com/ja_jp/codestar/latest/userguide/getting-started.html#git- You need to enter the user name / password of credentials)
The hierarchy of the cloned code is as follows, this time edit "index.py" and check that the response of Lambda changes
index.py
import json
import datetime
def handler(event, context):
data = {
# 'output': 'Hello World',
'output': 'Hello World CodeStar!',
'timestamp': datetime.datetime.utcnow().isoformat()
}
return {'statusCode': 200,
'body': json.dumps(data),
'headers': {'Content-Type': 'application/json'}}
If the push is successful, the PipeLine status will be updated on the CodeStar dashboard.
Confirm that Deploy is completed and the status of all phases is Green, access the endpoint of the app, and confirm that the code change is reflected.
--The following describes how to create a CodeStar project and how to edit code with a text editor, but you can also edit code and push with IDE. ――Looking back, I realized that there is a surprising process just by editing and pushing locally.
Select the project at the bottom left of the dashboard
When opened, you will see the project details and a list of resources created by CodeStar. As you can see, the project ID set in creation step 4 is used everywhere, which is why you need to be careful because the project ID cannot be changed as mentioned above. (If anyone knows how to change the project ID, please let me know!)
Recommended Posts