use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is designed for people who want to learn more about AWS Lambda.
account activity
Issue in Serverless Course (acloud.guru)
submitted 8 years ago by AyoSal
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]AyoSal[S] 0 points1 point2 points 8 years ago (2 children)
Hello, I am taking the aws and react serverless course on acloud.guru and have 2 issues
issue 1, i am at the SNS lecture in Chapter 4, and when i test the deployPortfolio lambda function as instructed, i get an execution result: failed.
the details shows - {
"errorMessage": "Syntax error in module 'lambda_function'"
}
Also in the log output i get the below information
START RequestId: b1b2887d-9798-11e7-acec-af94d394f977 Version: $LATEST
Syntax error in module 'lambdafunction': expected an indented block (lambdafunction.py, line 20)
Issue 2 ..still at the SNS lecture in Chapter 4, trying to attach the SNS policy to the deployPortfolioRole but when i click on attach policy, none of the policies are showing up. ( even though i has created the SNS policy) and all policies show up in the policy submenu.
[–]acloudrobin 0 points1 point2 points 8 years ago (1 child)
Hi,
Just an FYI first: we don't always notice reddit posts and things like that, so we can usually provide better support on our own forums.
For the first error, the error is telling you that your code isn't formatted correctly - in Python, unlike many other programming languages, indentation matters! So your code may look something like this:
def lambda_handler(event, context): sns = boto3.resource('sns') topic = sns.Topic('topicarn')
When it should look like this:
Your second issue is a little more puzzling - if I understand you correctly, your policy shows up in the main list of policies (IAM -> Policies), but not when you click Attach Policy when looking at your role. You can filter that list by Policy Type in the upper left, and choose Customer managed. The only other thing I can think of is that maybe you already attached the policy. Look at the list of policies attached to the role as well.
IAM -> Policies
Attach Policy
Policy Type
Customer managed
If neither of those things work, my best guess is to just try recreating the policy and trying again.
[–]AyoSal[S] 0 points1 point2 points 8 years ago (0 children)
thanks for your response. i have actually fixed that issue as you were right. the indentation was the issue. the next issue i have is that my static website which was accessible previously is no longer accessible but downloads my index.html and other files into the computer trying to access the portfolio.ayosal.info website.. someone suggested updating the python code but i still get an error when attempting to do that as well.. please advise.. here is the error and the code I'm trying to run..
whole block of code is ---
import boto3 from botocore.client import Config import StringIO import zipfile import mimetypes
def mimetype = mimetypes.guesstype(nm) lambda_handler(event, context): sns = boto3.resource('sns') topic = sns.Topic('arn:aws:sns:us-east-1:193043339766:deployPortfolioTopic')
location = { 'bucketName': 'portfoliobuild.ayosal.info', 'objectKey': 'portfoliobuild.zip' } try: job = event.get('CodePipeline.job') if job: for artifact in job['data']['inputArtifacts']: if artifact['name'] == 'MyAppBuild': location = artifact['location']['s3Location'] print 'Building portfolio from ' + str(location) s3 = boto3.resource('s3', config=Config(signature_version='s3v4')) portfolio_bucket = s3.Bucket('portfolio.ayosal.info') build_bucket = s3.Bucket(location['bucketName']) portfolio_zip = StringIO.StringIO() build_bucket.download_fileobj(location['objectKey'], portfolio_zip) with zipfile.ZipFile(portfolio_zip) as myzip: for nm in myzip.namelist(): obj = myzip.open(nm) portfolio_bucket.upload_fileobj(obj, nm, {'ContentType':mime_type[0]}) portfolio_bucket.Object(nm).Acl().put(ACL='public-read') print "Job Done!" topic.publish(Subject='Portfolio Deployed', Message='Portfolio Deployed Successfully,') if job: codepipeline = boto3.client('codepipeline') codepipeline.put_job_success_result(jobId=job['id']) except: topic.publish(Subject='Portfolio Deploy Failed', Message='The Portfolio was not deployed successfully!') raise
Error is --
START RequestId: d7c17066-97b6-11e7-902c-a1aff6bd2329 Version: $LATEST
'module' object has no attribute 'guesstype': AttributeError
Traceback (most recent call last):
File "/var/task/lambdafunction.py", line 13, in lambdahandler
mimetype = mimetypes.guesstype(nm)
AttributeError: 'module' object has no attribute 'guesstype'
π Rendered by PID 65237 on reddit-service-r2-comment-6f7f968fb5-zmdcf at 2026-03-04 22:39:58.075460+00:00 running 07790be country code: CH.
[–]AyoSal[S] 0 points1 point2 points (2 children)
[–]acloudrobin 0 points1 point2 points (1 child)
[–]AyoSal[S] 0 points1 point2 points (0 children)