IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] グループ最大級の規模 「綿半スーパーセンター上田店」がオープン |
https://www.itmedia.co.jp/business/articles/2208/02/news115.html
|
itmedia |
2022-08-02 13:37:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia PC USER] ドスパラ、全国11店舗で「パソコン組立教室」を開催 8月27日/28日 |
https://www.itmedia.co.jp/pcuser/articles/2208/02/news114.html
|
itmediapcuser |
2022-08-02 13:15:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] 10万円を社員に支給 はてな、在宅勤務の制度刷新で |
https://www.itmedia.co.jp/news/articles/2208/02/news113.html
|
itmedianews |
2022-08-02 13:06:00 |
TECH |
Techable(テッカブル) |
旅のサブスク「HafH」、タイやドバイなど海外約150の宿泊施設追加。5つ星ホテルも |
https://techable.jp/archives/183287
|
利用可能 |
2022-08-02 04:00:39 |
IT |
情報システムリーダーのためのIT情報専門サイト IT Leaders |
テラスカイ、クラウド型の勤怠管理「mitoco Work 勤怠」を提供、グループウェア「mitoco」の各機能と連携 | IT Leaders |
https://it.impress.co.jp/articles/-/23570
|
テラスカイ、クラウド型の勤怠管理「mitocoWork勤怠」を提供、グループウェア「mitoco」の各機能と連携ITLeadersテラスカイは年月日、勤怠管理アプリケーション「mitocoWork勤怠」の提供を開始した。 |
2022-08-02 13:12:00 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
DockerでVue+Node(Koa)+Nginx+MongoDB環境を作る |
https://qiita.com/kensoz/items/2fc0b707e91e6ec8920e
|
dockercompose |
2022-08-02 13:48:53 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
【Google MAP】2点間orクリックによる多地点間の距離を取得する(直線距離) |
https://qiita.com/yoshi_yast/items/1cc5cc4ca1ef74de6170
|
google |
2022-08-02 13:37:09 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
NHK-FMのJAZZ |
https://qiita.com/yamori813/items/9f5fa33e7a8ea65ae058
|
idgenre |
2022-08-02 13:29:31 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
5行でわかるプッシュ通知【VAPID】 |
https://qiita.com/relu/items/6b37496cad8dfc542d7f
|
vapid |
2022-08-02 13:04:42 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Rails】rails db:migrateが実行できない / PG::DuplicateTable: ERROR: relation "users" already exists / PG::ObjectInUse: ERROR: database "scaffold_app_development" is being accessed by other users |
https://qiita.com/Ryo-2103/items/6b14df92363c9cee378a
|
【Rails】railsdbmigrateが実行できないPGDuplicateTableERRORrelationquotusersquotalreadyexistsPGObjectInUseERRORdatabasequotscaffoldappdevelopmentquotisbeingaccessedbyotherusers実現したいことrailsdbmigrateをエラーなく、実行する。 |
2022-08-02 13:51:09 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
初心者学習メモ スネークケースとキャメルケース |
https://qiita.com/ken_fuji/items/0b32583678d825b54446
|
言葉 |
2022-08-02 13:49:16 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
DockerでVue+Node(Koa)+Nginx+MongoDB環境を作る |
https://qiita.com/kensoz/items/2fc0b707e91e6ec8920e
|
dockercompose |
2022-08-02 13:48:53 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
Docker+Laravel9+MySQL5+phpmyadmin+Inertia.js(Vue.js)の開発環境を構築 (Windows) |
https://qiita.com/backstreet/items/e7ff5b6c09408a94e5aa
|
desktopcomposervcomp |
2022-08-02 13:17:06 |
Git |
Gitタグが付けられた新着投稿 - Qiita |
error: failed to push some refs to 'github.com:jojo232/raistech-aws202208.git' |
https://qiita.com/jojo232/items/6a2286be32b4d907149f
|
failedtopushsomerefsto |
2022-08-02 13:46:18 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Rails】rails db:migrateが実行できない / PG::DuplicateTable: ERROR: relation "users" already exists / PG::ObjectInUse: ERROR: database "scaffold_app_development" is being accessed by other users |
https://qiita.com/Ryo-2103/items/6b14df92363c9cee378a
|
【Rails】railsdbmigrateが実行できないPGDuplicateTableERRORrelationquotusersquotalreadyexistsPGObjectInUseERRORdatabasequotscaffoldappdevelopmentquotisbeingaccessedbyotherusers実現したいことrailsdbmigrateをエラーなく、実行する。 |
2022-08-02 13:51:09 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
初心者学習メモ スネークケースとキャメルケース |
https://qiita.com/ken_fuji/items/0b32583678d825b54446
|
言葉 |
2022-08-02 13:49:16 |
海外TECH |
DEV Community |
Build a Serverless URL shortener with Go |
https://dev.to/abhirockzz/build-a-serverless-url-shortener-with-go-10i2
|
Build a Serverless URL shortener with GoUsing AWS Lambda DynamoDB and API GatewayThis blog post covers how to build a Serverless URL shortener application using Go It leverages AWS Lambda for business logic DynamoDB for persistence and API Gateway to provide the HTTP endpoints to access and use the application The sample application presented in this blog is a trimmed down version of bit ly or other solutions you may have used or encountered It s structured as follows I will start off with a quick introduction and dive into how to deploy try the solution After that I will focus on the code itself This will cover The part which is used to write the infrastructure using Go bindings for AWS CDK And also the core business logic which contains the Lambda function using Lambda Go support as well as the DynamoDB operations using the DynamoDB Go SDK In this blog you will learn How to use the DynamoDB Go SDK v to execute CRUD operations such as PutItem GetItem UpdateItem and DeleteItemHow to use AWS CDK Go bindings to deploy a Serverless application to create and manage a DynamoDB table Lambda functions API Gateway and other components as well Once you deploy the application you will be able to create short codes for URLs using the endpoint exposed by the API Gateway and also access them create short code for a URL e g curl i X POST d H Content Type text plain URL SHORTENER APP URL access URL via short codecurl i URL SHORTENER APP URL lt short code gt Lets get started Deploy the Serverless applicationBefore you proceed make sure you have the Go programming language v or higher and AWS CDK installed Clone the project and change to the right directory git clone cd cdkTo start the deployment all you will do is run a single command cdk deploy and wait for a bit You will see a long list of resources that will be created and will need to provide your confirmation to proceed Don t worry in the next section I will explain what s happening cdk deploy outputBundling asset ServerlessURLShortenerStack create url function Code Stage Bundling asset ServerlessURLShortenerStack access url function Code Stage Bundling asset ServerlessURLShortenerStack update url status function Code Stage Bundling asset ServerlessURLShortenerStack delete url function Code Stage Synthesis time sThis deployment will make potentially sensitive changes according to your current security approval level require approval broadening Please confirm you intend to make the following modifications Do you wish to deploy these changes y n This will start creating the AWS resources required for our application If you want to see the AWS CloudFormation template which will be used behind the scenes run cdk synth and check the cdk out folderYou can keep track of the progress in the terminal or navigate to AWS console CloudFormation gt Stacks gt ServerlessURLShortenerStackOnce all the resources are created you can try out the application You should have Four Lambda functions and related resources A DynamoDB tableAn API Gateway as well as routes integrations along with a few others like IAM roles etc Before you proceed get the API Gateway endpoint that you will need to use It s available in the stack output in the terminal or the Outputs tab in the AWS CloudFormation console for your Stack Shorten some URLs Start by generating short codes for a few URLs export the API Gateway endpointexport URL SHORTENER APP URL lt replace with apigw endpoint above gt for example export URL SHORTENER APP URL invoke the endpoint to create short codescurl i X POST d H Content Type text plain URL SHORTENER APP URLcurl i X POST d H Content Type text plain URL SHORTENER APP URLcurl i X POST d H Content Type text plain URL SHORTENER APP URLTo generate a short code you need to pass the original URL in the payload body as part of a HTTP POST request for e g Content Type text plain is important otherwise API Gateway will do base encoding of your payloadIf all goes well you should get a HTTP along with the short code in the HTTP response as a JSON payload HTTP date Fri Jul GMTcontent type text plain charset utf content length apigw requestid VTzPsgmSoAMESdA short code eeadb To confirm check the DynamoDB table Notice an active attribute there More on this soonAccess the URL using the short codeWith services like bit ly etc you typically create short links for your URLs and share them with the world We will do something similar Now that you have the short code generated you can share the link it s not really a short link like bit ly but that s ok for now with others and once they access it they would see the original URL The access link will have the following format lt URL SHORTENER APP URL gt lt generated short code gt for e g If you navigate to the link using a browser you will be automatically redirected to the original URL that you had specified To see what s going on try the same with curl curl i URL SHORTENER APP URL lt short code gt examplecurl i This is simply an HTTP GET request If all goes well you should get an HTTP response StatusFound and the URL re direction happens due to the the Location HTTP header which contains the original URL HTTP date Fri Jul GMTcontent length location apigw requestid VTDhNLIAMESw How about using a short code that does not exist Set the statusYou can enable and disable the short codes The original URL will only be accessible if the association is in active state To disable a short code curl i X PUT d active false H Content Type application json URL SHORTENER APP URL lt short code gt examplecurl i X PUT d active false H Content Type application json This is an HTTP PUT request with a JSON payload that specifies the status false in this case refers to disable along with the short code which is a path parameter to the API Gateway endpoint If all works well you should see a HTTP No Content response HTTP date Fri Jul GMTapigw requestid VTDigyIAMEVHw Check the DynamoDB record the active attribute must have switched to false As an exercise try the following access the URL via the same short code now and check the response access an invalid short code i e that does not existenable a disabled URL use active true Ok so far we have covered all operations except delete Lets try that and wrap up the CRUD Deletecurl i X DELETE URL SHORTENER APP URL lt short code gt examplecurl i X DELETE Nothing too surprising We use a HTTP DELETE along with the short code Just like in case of update you should get a HTTP response HTTP date Fri Jul GMTapigw requestid VTNzgjnIAMEVKA But this time of course the DynamoDB record should have been deleted confirm the same What happens when you try to delete a short code that does not exist Don t forget to clean up Once you re done to delete all the services simply use cdk destroyAlright now that you ve actually seen what the application does let s move on to the how We will start with the AWS CDK code and explore how it does all the heavy lifting behind to setup the infrastructure for our Serverless URL shortener service With AWS CDK Infrastructure IS code You can check out the code in this GitHub repo I will walk you through the keys parts of the NewServerlessURLShortenerStack function which defines the workhorse of our CDK application I have omitted some of the code for brevityWe start by creating a DynamoDB table A primary key is all that s required in order to do that in this case shortcode we don t have range sort key in this example dynamoDBTable awsdynamodb NewTable stack jsii String url shortener dynamodb table amp awsdynamodb TableProps PartitionKey amp awsdynamodb Attribute Name jsii String shortCodeDynamoDBAttributeName Type awsdynamodb AttributeType STRING Then we create an API Gateway HTTP API with just one line of code urlShortenerAPI awscdkapigatewayvalpha NewHttpApi stack jsii String url shortner http api nil We move on to the first Lambda function that creates short codes for URLs Notice that we use an experimental module awscdklambdagoalpha here is the stable version at the time of writing If your Go project is structured in a specific way details here and you specify its path using Entry it will automatically take care of building packaging and deploying your Lambda function Not bad at all In addition to Local bundling as used in this example Docker based builds are also supported createURLFunction awscdklambdagoalpha NewGoFunction stack jsii String create url function amp awscdklambdagoalpha GoFunctionProps Runtime awslambda Runtime GO X Environment funcEnvVar Entry jsii String createShortURLFunctionDirectory dynamoDBTable GrantWriteData createURLFunction Finally we add the last bit of plumbing by creating a Lambda HTTP API integration notice how the Lambda function variable createURLFunction is referenced and adding a route to the HTTP API we had created this in turn refers to the Lambda integration createFunctionIntg awscdkapigatewayvintegrationsalpha NewHttpLambdaIntegration jsii String create function integration createURLFunction nil urlShortenerAPI AddRoutes amp awscdkapigatewayvalpha AddRoutesOptions Path jsii String Methods amp awscdkapigatewayvalpha HttpMethod awscdkapigatewayvalpha HttpMethod POST Integration createFunctionIntg This was just for one function we have three more remaining The good part is that the template for all these are similar i e create the functiongrant permission for DynamoDBwire it up with API Gateway with the correct HTTP method i e POST PUT DELETE So I will not repeat it over here Feel free to grok through the rest of the code Now that you understand the magic behind the one click infrastructure setup let s move on to the core logic of the application URL shortener Lambda function and DynamoDB logicThere are four different functions all of which are in their respective folders and all of them have a few things in common in the way they operate They do dome initial processing process the payload or extract the path parameter from the URL etc Invoke a common database layer to execute the CRUD functionality more on this soon Handle errors as appropriate and return responseWith that knowledge it should be easy to follow along the code As before some parts of the code have been omitted for brevityCreate functionfunc handler ctx context Context req events APIGatewayVHTTPRequest events APIGatewayVHTTPResponse error url req Body shortCode err db SaveURL url if err nil handle error response Response ShortCode shortCode respBytes err json Marshal response if err nil handle error return events APIGatewayVHTTPResponse StatusCode http StatusCreated Body string respBytes nil This function starts by reading the payload of the HTTP request body this is a string which has the URL for which the short code is being created It invokes the database layer to try and save this record to DynamoDB and handles errors Finally it returns a JSON response with the short code Here is the function that actually interacts with DynamoDB to get the job done func SaveURL longurl string string error shortCode uuid New String item make map string types AttributeValue item longURLDynamoDBAttributeName amp types AttributeValueMemberS Value longurl item shortCodeDynamoDBAttributeName amp types AttributeValueMemberS Value shortCode item activeDynamoDBAttributeName amp types AttributeValueMemberBOOL Value true err client PutItem context Background amp dynamodb PutItemInput TableName aws String table Item item if err nil handle error return shortCode nil For the purposes of this sample app the short code is created by generating a UUID and trimming out the last digits It s easy to replace this with another technique all that matters is that you generate a unique string that can work as a short code Then it all about calling the PutItem API with the required data Access the URLfunc handler ctx context Context req events APIGatewayVHTTPRequest events APIGatewayVHTTPResponse error shortCode req PathParameters pathParameterName longurl err db GetLongURL shortCode if err nil handle error return events APIGatewayVHTTPResponse StatusCode http StatusFound Headers map string string locationHeader longurl nil When someone accesses the short link as demonstrated in the earlier section the short code is passed in as a path parameter e g http lt api gw url gt lt short code gt the database layer is invoked to get the corresponding URL from DynamoDB table errors are handled as needed Finally the response is returned to the user wherein the status code is and the URL is passed in the Location header This is what re directs you to the original URL when you enter the short code in the browser Here is the DynamoDB call func GetLongURL shortCode string string error op err client GetItem context Background amp dynamodb GetItemInput TableName aws String table Key map string types AttributeValue shortCodeDynamoDBAttributeName amp types AttributeValueMemberS Value shortCode if err nil handle error if op Item nil return ErrUrlNotFound activeAV op Item activeDynamoDBAttributeName active activeAV types AttributeValueMemberBOOL Value if active return ErrUrlNotActive longurlAV op Item longURLDynamoDBAttributeName longurl longurlAV types AttributeValueMemberS Value return longurl nil The first step is to use GetItem API to get the DynamoDB record containing URL and status corresponding to the short code If the item object in the response is nil we can be sure that a record with that short code does not exist we return a custom error which can be helpful for our function which can then return an appropriate response to the caller of the API e g a HTTP We also check the status active or not and return an error if active is set to false If all is well the URL is returned to the caller Update statusfunc handler ctx context Context req events APIGatewayVHTTPRequest events APIGatewayVHTTPResponse error var payload Payload reqBody req Body err json Unmarshal byte reqBody amp payload if err nil handle error shortCode req PathParameters pathParameterName err db Update shortCode payload Active if err nil handle error return events APIGatewayVHTTPResponse StatusCode http StatusNoContent nil The first step is to marshal the HTTP request payload which is a JSON e g active false and then get the short code from the path parameter The database layer is invoked to update the status and handle errors func Update shortCode string status bool error update expression Set expression Name activeDynamoDBAttributeName expression Value status updateExpression expression NewBuilder WithUpdate update Build condition expression AttributeExists expression Name shortCodeDynamoDBAttributeName conditionExpression expression NewBuilder WithCondition condition Build err client UpdateItem context Background amp dynamodb UpdateItemInput TableName aws String table Key map string types AttributeValue shortCodeDynamoDBAttributeName amp types AttributeValueMemberS Value shortCode UpdateExpression updateExpression Update ExpressionAttributeNames updateExpression Names ExpressionAttributeValues updateExpression Values ConditionExpression conditionExpression Condition if err nil amp amp strings Contains err Error ConditionalCheckFailedException return ErrUrlNotFound return err The UpdateItem API call takes care of changing the status It s fairly simple except for the all these expressions that you need especially if you re new to the concept The first one mandatory is the update expression where you specify the attribute you need to set active in this case and its value The second one makes sure that you are updating the status for a short code that actually exists in the table This is important since otherwise the UpdateItem API call will insert a new item we don t want that Instead of rolling out the expressions by hand we use the expressions package Delete short codefunc handler ctx context Context req events APIGatewayVHTTPRequest events APIGatewayVHTTPResponse error shortCode req PathParameters pathParameterName err db Delete shortCode if err nil handle error return events APIGatewayVHTTPResponse StatusCode http StatusNoContent nil The delete handler is no different After the short code to be deleted is extracted from the path parameter the database layer is invoked to remove it from the DynamoDB table The result returned to the user is either an HTTP on success or the error func Delete shortCode string error condition expression AttributeExists expression Name shortCodeDynamoDBAttributeName conditionExpression expression NewBuilder WithCondition condition Build err client DeleteItem context Background amp dynamodb DeleteItemInput TableName aws String table Key map string types AttributeValue shortCodeDynamoDBAttributeName amp types AttributeValueMemberS Value shortCode ConditionExpression conditionExpression Condition ExpressionAttributeNames conditionExpression Names ExpressionAttributeValues conditionExpression Values if err nil amp amp strings Contains err Error ConditionalCheckFailedException return ErrUrlNotFound return err Just like UpdateItem API the DeleteItem API also takes in a condition expression If there is no record in the DynamoDB table with the given short code an error is returned Otherwise the record is deleted That completes the code walk through Wrap upIn this blog post you learnt how to use DynamoDB Go SDK using a URL Shortener sample application You also integrated it with AWS Lambda and API Gateway to build a Serverless solution whose infrastructure was also defined using actual code as opposed to yaml JSON etc thanks to the Go support in AWS CDK |
2022-08-02 04:13:20 |
医療系 |
医療介護 CBnews |
最後の医薬品回収に着手、小林化工-製販業許可の取り下げへ |
https://www.cbnews.jp/news/entry/20220802131214
|
医薬品医療機器総合機構 |
2022-08-02 13:50:00 |
海外ニュース |
Japan Times latest articles |
Japan swelters as temperatures exceed 30 C at over 300 locations nationwide |
https://www.japantimes.co.jp/news/2022/08/02/national/hot-weather-warning/
|
Japan swelters as temperatures exceed C at over locations nationwideThe government issued an alert covering wide areas across the country asking people to drink water and avoid going outdoors in order to prevent heat |
2022-08-02 13:21:51 |
ニュース |
BBC News - Home |
Ayman al-Zawahiri: Al-Qaeda leader killed in US drone strike |
https://www.bbc.co.uk/news/world-asia-62387167?at_medium=RSS&at_campaign=KARANGA
|
biden |
2022-08-02 04:07:36 |
北海道 |
北海道新聞 |
ウオータースライダーで4人けが 堺市営プール、利用停止 |
https://www.hokkaido-np.co.jp/article/713098/
|
市営 |
2022-08-02 13:07:37 |
北海道 |
北海道新聞 |
駅空港に117無料検査場 山際再生相、今月5~18日 |
https://www.hokkaido-np.co.jp/article/713104/
|
山際大志郎 |
2022-08-02 13:12:00 |
北海道 |
北海道新聞 |
「臨時国会欠席」ガーシー氏渡航届は不許可 参院議運委、全会一致で |
https://www.hokkaido-np.co.jp/article/713103/
|
全会一致 |
2022-08-02 13:07:00 |
マーケティング |
MarkeZine |
米国の最新マーケティングトレンドを一気に解説 コンテンツ管理からSEO、メタバースまで【参加無料】 |
http://markezine.jp/article/detail/39622
|
参加無料 |
2022-08-02 13:15:00 |
IT |
週刊アスキー |
ペアリング不要で使えるiPad専用スタイラスペン「PaDraw(パドロー)」 |
https://weekly.ascii.jp/elem/000/004/100/4100279/
|
padraw |
2022-08-02 13:50:00 |
IT |
週刊アスキー |
『ドラクエX』祝10周年!さまざまな縁のある人たちからの「お祝いメッセージ」が公開 |
https://weekly.ascii.jp/elem/000/004/100/4100280/
|
mmorpg |
2022-08-02 13:45:00 |
IT |
週刊アスキー |
夏のガリガリ君といえばやはりこれ! 「ガリガリ君梨」今年も登場 |
https://weekly.ascii.jp/elem/000/004/100/4100275/
|
赤城乳業 |
2022-08-02 13:30:00 |
IT |
週刊アスキー |
Steam版『初音ミク Project DIVA MEGA39’s+』が初のセールを実施!8月5日1時59分まで最大30%オフ |
https://weekly.ascii.jp/elem/000/004/100/4100276/
|
edition |
2022-08-02 13:25:00 |
マーケティング |
AdverTimes |
キングジム、経営企画部担当ほか(22年9月15日付) |
https://www.advertimes.com/20220802/article391795/
|
執行役員 |
2022-08-02 04:27:23 |
マーケティング |
AdverTimes |
電通コーポレートワン、経理センターセンター長補佐(22年8月1日付) |
https://www.advertimes.com/20220802/article391831/
|
電通 |
2022-08-02 04:07:56 |
コメント
コメントを投稿