1

我创建了AWS Lambda函数,我需要通过encrption从客户端到亚马逊网络服务。我从亚马逊文档中看到的唯一方法是设置一个api网关。我部署,并得到该样品作为终点:在ios上使用亚马逊API网关

https://my-api-id.execute-api.region-id.amazonaws.com/test/mydemoresourc 

要访问,这是做像这样的唯一途径:

NSURL *url = [NSURL URLWithString:@"https://portkey.formspring.me/login/"]; 

//initialize a request from url 
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[url  standardizedURL]]; 

//set http method 
[request setHTTPMethod:@"POST"]; 
//initialize a post data 

NSDictionary *postDict = [NSDictionary dictionaryWithObjectsAndKeys:@"username", @"username", 
          @"password", @"password", nil]; 

NSError *error=nil; 

NSData* jsonData = [NSJSONSerialization dataWithJSONObject:postDict 
                options:NSJSONWritingPrettyPrinted  error:&error]; 



[request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 

//set post data of request 
[request setHTTPBody:jsonData]; 

//initialize a connection from request 
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

//start the connection 
[connection start]; 

抑或是AWS IOS SDK有不同的方式做它在文档或样本中的某处?

回答

1

您试图执行的操作也是调用AWS Lambda函数的有效方式,但您也可以使用Amazon Cognito服务的一种方式。

请参阅此链接作进一步了解:

Building a Mobile Backend Using AWS Lambda

Execute Code On Demand with Amazon Lambda

希望这有助于你。

+0

我原本想使用它,但我想从客户端(iphone)到系统(aws)的数据进行加密。有没有办法使用SSL /加密以上使用? – cdub

+0

您的意思是高效还是低效? – cdub

+0

AWS API网关是一种有效的方法。如果您想要将SSL应用到您的API网关调用,那么该解决方案就是这样的一个解决方案:http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html –